Hello community,
here is the log from the commit of package libproxy for openSUSE:Factory
checked in at Fri Jun 11 10:26:55 CEST 2010.
--------
--- GNOME/libproxy/libproxy-plugins.changes 2010-05-28 17:21:05.000000000 +0200
+++ /mounts/work_src_done/STABLE/libproxy/libproxy-plugins.changes 2010-06-11 10:26:27.049131000 +0200
@@ -1,0 +2,15 @@
+Mon Jun 7 17:01:55 UTC 2010 - dimstar@opensuse.org
+
+- Update to version 0.4.3:
+ + Test can now be out-compiled using BUILD_TESTING=OFF
+ + Fixed python binding not handling NULL pointer
+ + Pyhton binding now support Python version 3
+ + Rewrote URL parser to comply with unit test (bnc#612007)
+ + Username and password are now URL encoded
+ + Scheme comparison is now non-case sensitive
+ + Fixed deadlock using WebKit as PAC runner
+ + Fixed OS X compilation of Perl bindings
+- libmodman0_0_0 is now correctly called libmodman0, follow this
+ change also in baselibs.conf
+
+-------------------------------------------------------------------
libproxy.changes: same change
calling whatdependson for head-i586
Old:
----
libproxy-0.4.2.tar.bz2
New:
----
libproxy-0.4.3.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libproxy-plugins.spec ++++++
--- /var/tmp/diff_new_pack.QqEMWz/_old 2010-06-11 10:26:38.000000000 +0200
+++ /var/tmp/diff_new_pack.QqEMWz/_new 2010-06-11 10:26:38.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package libproxy-plugins (Version 0.4.2)
+# spec file for package libproxy-plugins (Version 0.4.3)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2010 Dominique Leuenberger, Amsterdam, Netherlands.
@@ -38,7 +38,7 @@
Name: libproxy-plugins
Group: System/Libraries
Summary: Libproxy provides consistent proxy configuration to applications
-Version: 0.4.2
+Version: 0.4.3
Release: 1
Source: http://libproxy.googlecode.com/files/%{_name}-%{version}.tar.bz2
Source99: baselibs.conf
@@ -133,12 +133,14 @@
* a standard way of dealing with proxy settings across all scenarios
-%package -n libmodman0_0_0
+%package -n libmodman0
License: GPLv2+ ; LGPLv2.1+
Summary: Libproxy's Module Management Library
Group: System/Libraries
+Obsoletes: libmodman0_0_0 < %{version}
+Provides: libmodman0_0_0 = %{version}
-%description -n libmodman0_0_0
+%description -n libmodman0
A module management library taking care of loading / unload modules
including heuristics in detecting which bindings might already
be used by an application and favouring this one.
@@ -297,7 +299,7 @@
-DWITH_VALA=yes \
-DPERL_VENDORINSTALL=yes \
..
-%{__make} %{?jobs:-j%jobs} VERBOSE=1
+%{__make} %{?jobs:-j%jobs}
%install
cd build
@@ -325,11 +327,11 @@
%post -n libproxy1 -p /sbin/ldconfig
-%post -n libmodman0_0_0 -p /sbin/ldconfig
+%post -n libmodman0 -p /sbin/ldconfig
%postun -n libproxy1 -p /sbin/ldconfig
-%postun -n libmodman0_0_0 -p /sbin/ldconfig
+%postun -n libmodman0 -p /sbin/ldconfig
%files tools
%defattr(-, root, root)
@@ -347,7 +349,7 @@
#%{_libdir}/libproxy/%{version}/modules/config_direct.so
#%{_libdir}/libproxy/%{version}/modules/ignore_*.so
-%files -n libmodman0_0_0
+%files -n libmodman0
%defattr(-, root, root)
%{_libdir}/libmodman.so.*
libproxy.spec: same change
++++++ baselibs.conf ++++++
--- /var/tmp/diff_new_pack.QqEMWz/_old 2010-06-11 10:26:38.000000000 +0200
+++ /var/tmp/diff_new_pack.QqEMWz/_new 2010-06-11 10:26:38.000000000 +0200
@@ -1,4 +1,4 @@
-libmodman0_0_0
+libmodman0
libproxy1
libproxy1-config-gnome
supplements "packageand(libproxy1-<targettype>:libproxy1-gnome)"
++++++ libproxy-0.4.2.tar.bz2 -> libproxy-0.4.3.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/CMakeLists.txt new/libproxy-0.4.3/CMakeLists.txt
--- old/libproxy-0.4.2/CMakeLists.txt 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/CMakeLists.txt 2010-06-07 17:57:23.000000000 +0200
@@ -2,10 +2,12 @@
cmake_minimum_required(VERSION 2.6)
project(libproxy)
+INCLUDE(CTest)
+
### Enable packaging
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 4)
-set(CPACK_PACKAGE_VERSION_PATCH 2)
+set(CPACK_PACKAGE_VERSION_PATCH 3)
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_IGNORE_FILES "CMakeCache.txt;install_manifest.txt;utils/proxy$;/Testing/;/Makefile$;\\\\.cmake$;\\\\.tar.gz$;\\\\.so[.0-9]*$;/build/;/_CPack_Packages/;/CMakeFiles/;/CVS/;/\\\\.svn/;/\\\\.git/;\\\\.swp$;\\\\.#;/#")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/NEWS new/libproxy-0.4.3/NEWS
--- old/libproxy-0.4.2/NEWS 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/NEWS 2010-06-07 17:57:23.000000000 +0200
@@ -1,3 +1,14 @@
+New in version 0.4.3
+===============================
+* Test can now be out-compiled using BUILD_TESTING=OFF
+* Fixed python binding not handling NULL pointer
+* Pyhton binding now support Python version 3
+* Rewrote URL parser to comply with unit test
+* Username and password are now URL encoded
+* Scheme comparison is now non-case sensitive
+* Fixed deadlock using WebKit has PAC runner
+* Fixed OS X compilation of Perl bindings
+
New in version 0.4.2
===============================
* Fixed python binding that failed on missing px_free symbole
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/bindings/libproxy.py new/libproxy-0.4.3/bindings/libproxy.py
--- old/libproxy-0.4.2/bindings/libproxy.py 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/bindings/libproxy.py 2010-06-07 17:57:23.000000000 +0200
@@ -30,13 +30,13 @@
_libc = ctypes.cdll.msvcrt
else:
if not ctypes.util.find_library("c"):
- raise ImportError, "Unable to import C Library!?!"
+ raise ImportError("Unable to import C Library!?!")
_libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c"))
# Load libproxy
if not ctypes.util.find_library("proxy"):
- raise ImportError, "Unable to import libproxy!?!?"
+ raise ImportError("Unable to import libproxy!?!?")
_libproxy = ctypes.cdll.LoadLibrary(ctypes.util.find_library("proxy"))
@@ -66,6 +66,11 @@
break
"""
+ class ProxyResolutionError(RuntimeError):
+ """Exception raised when proxy cannot be resolved generally
+ due to invalid URL"""
+ pass
+
def __init__(self):
self._pf = _libproxy.px_proxy_factory_new()
@@ -97,10 +102,15 @@
"""
if type(url) != str:
- raise TypeError, "url must be a string!"
+ raise TypeError("url must be a string!")
proxies = []
array = _libproxy.px_proxy_factory_get_proxies(self._pf, url)
+
+ if not bool(array):
+ raise ProxyFactory.ProxyResolutionError(
+ "Can't resolve proxy for '%s'" % url)
+
i=0
while array[i]:
proxies.append(str(ctypes.cast(array[i], ctypes.c_char_p).value))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/bindings/perl/src/CMakeLists.txt new/libproxy-0.4.3/bindings/perl/src/CMakeLists.txt
--- old/libproxy-0.4.2/bindings/perl/src/CMakeLists.txt 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/bindings/perl/src/CMakeLists.txt 2010-06-07 17:57:23.000000000 +0200
@@ -19,7 +19,7 @@
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/perl/blib/arch/auto/Net)
add_library(PLlibproxy SHARED ${Libproxy_LIB_SRCS})
-target_link_libraries(PLlibproxy libproxy)
+target_link_libraries(PLlibproxy ${PERL_LIBRARY} libproxy)
set_target_properties(PLlibproxy PROPERTIES OUTPUT_NAME "Libproxy")
set_target_properties(PLlibproxy PROPERTIES PREFIX "")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/bindings/perl/src/Libproxy.c new/libproxy-0.4.3/bindings/perl/src/Libproxy.c
--- old/libproxy-0.4.2/bindings/perl/src/Libproxy.c 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/bindings/perl/src/Libproxy.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,207 +0,0 @@
-/*
- * This file was generated automatically by ExtUtils::ParseXS version 2.2203 from the
- * contents of Libproxy.xs. Do not edit this file, edit Libproxy.xs instead.
- *
- * ANY CHANGES MADE HERE WILL BE LOST!
- *
- */
-
-#line 1 "Libproxy.xs"
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include
-
-
-void XS_pack_charPtrPtr( SV * arg, char ** array, int count) {
- int i;
- AV * avref;
- avref = (AV*)sv_2mortal((SV*)newAV());
- for (i=0; i= 9)
- if (PL_unitcheckav)
- call_list(PL_scopestack_ix, PL_unitcheckav);
-#endif
- XSRETURN_YES;
-}
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libmodman/CMakeLists.txt new/libproxy-0.4.3/libmodman/CMakeLists.txt
--- old/libproxy-0.4.2/libmodman/CMakeLists.txt 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/libmodman/CMakeLists.txt 2010-06-07 17:57:23.000000000 +0200
@@ -3,68 +3,10 @@
if(NOT WIN32)
target_link_libraries(libmodman dl)
endif()
-set_target_properties(libmodman PROPERTIES PREFIX "" VERSION 0 SOVERSION 0.0.0)
+set_target_properties(libmodman PROPERTIES PREFIX "" VERSION 0.0.0 SOVERSION 0)
install(TARGETS libmodman DESTINATION ${libdir})
### Tests
-# Functions
-function(mm_create_module MODTYPE MODNAME MODCOND MODSYMB MODSMOD)
- configure_file(test/modules/module.cpp.in libmodman/test/${MODTYPE}_${MODNAME}.cpp @ONLY)
- if(NOT IS_DIRECTORY test/modules/${MODTYPE})
- file(MAKE_DIRECTORY test/modules/${MODTYPE})
- endif()
- include_directories(../)
- add_library(${MODTYPE}_${MODNAME} MODULE libmodman/test/${MODTYPE}_${MODNAME}.cpp)
- set_target_properties(${MODTYPE}_${MODNAME} PROPERTIES PREFIX "" LIBRARY_OUTPUT_DIRECTORY test/modules/${MODTYPE})
- target_link_libraries(${MODTYPE}_${MODNAME} libmodman)
-endfunction(mm_create_module)
-
-function(mm_create_program name EXTTYPE)
- add_executable(${name} test/main.cpp)
- target_link_libraries(${name} libmodman)
- set_property(TARGET ${name} PROPERTY COMPILE_DEFINITIONS EXTTYPE=${EXTTYPE}_extension)
- if(${ARGC} GREATER 2)
- target_link_libraries(${name} ${ARGN};libmodman)
- set_property(TARGET ${name} PROPERTY COMPILE_DEFINITIONS EXTTYPE=${EXTTYPE}_extension;SYMB=1)
- endif()
-endfunction(mm_create_program)
-
-# Modules
-mm_create_module(condition one false NULL NULL)
-mm_create_module(condition two true NULL NULL)
-mm_create_module(singleton one true NULL NULL)
-mm_create_module(singleton two true NULL NULL)
-mm_create_module(sorted one true NULL NULL)
-mm_create_module(sorted two true NULL NULL)
-mm_create_module(builtin one true NULL NULL)
-if (WIN32)
-mm_create_module(symbol one true \"asdfoia\" \"ws2_32\")
-mm_create_module(symbol two true \"recv\" \"ws2_32\")
-else()
-mm_create_module(symbol one true \"asdfoia\" \"z\")
-mm_create_module(symbol two true \"deflate\" \"z\")
-endif()
-
-# Programs
-mm_create_program(condition condition)
-mm_create_program(singleton singleton)
-mm_create_program(sorted sorted)
-mm_create_program(symbol symbol)
-if (WIN32)
-mm_create_program(symbollnk symbol ws2_32)
-else()
-mm_create_program(symbollnk symbol z)
-endif()
-add_executable(builtin test/builtin.cpp libmodman/test/builtin_one.cpp)
-target_link_libraries(builtin libmodman)
-set_property(TARGET builtin PROPERTY COMPILE_DEFINITIONS EXTTYPE=builtin_extension;BUILTIN_MODULE="extension";MM_MODULE_BUILTIN=extension)
-
-# Tests
-add_test(NAME condition COMMAND condition $ two)
-add_test(NAME singleton COMMAND singleton $ one)
-add_test(NAME sorted COMMAND sorted $ two one)
-add_test(NAME symbol COMMAND symbollnk $ two)
-add_test(NAME nosymbol COMMAND symbol $)
-add_test(NAME nosymreq COMMAND symbol $ one)
-add_test(NAME builtin COMMAND builtin)
-
+if (BUILD_TESTING)
+ add_subdirectory (test)
+endif (BUILD_TESTING)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libmodman/test/CMakeLists.txt new/libproxy-0.4.3/libmodman/test/CMakeLists.txt
--- old/libproxy-0.4.2/libmodman/test/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
+++ new/libproxy-0.4.3/libmodman/test/CMakeLists.txt 2010-06-07 17:57:23.000000000 +0200
@@ -0,0 +1,65 @@
+#####
+## LibModMan Tests
+####
+
+# Functions
+function(mm_create_module MODTYPE MODNAME MODCOND MODSYMB MODSMOD)
+ configure_file(modules/module.cpp.in libmodman/test/${MODTYPE}_${MODNAME}.cpp @ONLY)
+ if(NOT IS_DIRECTORY modules/${MODTYPE})
+ file(MAKE_DIRECTORY modules/${MODTYPE})
+ endif()
+ include_directories(../../)
+ add_library(${MODTYPE}_${MODNAME} MODULE libmodman/test/${MODTYPE}_${MODNAME}.cpp)
+ set_target_properties(${MODTYPE}_${MODNAME} PROPERTIES PREFIX "" LIBRARY_OUTPUT_DIRECTORY modules/${MODTYPE})
+ target_link_libraries(${MODTYPE}_${MODNAME} libmodman)
+endfunction(mm_create_module)
+
+function(mm_create_program name EXTTYPE)
+ add_executable(${name} main.cpp)
+ target_link_libraries(${name} libmodman)
+ set_property(TARGET ${name} PROPERTY COMPILE_DEFINITIONS EXTTYPE=${EXTTYPE}_extension)
+ if(${ARGC} GREATER 2)
+ target_link_libraries(${name} ${ARGN};libmodman)
+ set_property(TARGET ${name} PROPERTY COMPILE_DEFINITIONS EXTTYPE=${EXTTYPE}_extension;SYMB=1)
+ endif()
+endfunction(mm_create_program)
+
+# Modules
+mm_create_module(condition one false NULL NULL)
+mm_create_module(condition two true NULL NULL)
+mm_create_module(singleton one true NULL NULL)
+mm_create_module(singleton two true NULL NULL)
+mm_create_module(sorted one true NULL NULL)
+mm_create_module(sorted two true NULL NULL)
+mm_create_module(builtin one true NULL NULL)
+if (WIN32)
+ mm_create_module(symbol one true \"asdfoia\" \"ws2_32\")
+ mm_create_module(symbol two true \"recv\" \"ws2_32\")
+else()
+ mm_create_module(symbol one true \"asdfoia\" \"z\")
+ mm_create_module(symbol two true \"deflate\" \"z\")
+endif()
+
+# Programs
+mm_create_program(condition condition)
+mm_create_program(singleton singleton)
+mm_create_program(sorted sorted)
+mm_create_program(symbol symbol)
+if (WIN32)
+ mm_create_program(symbollnk symbol ws2_32)
+else()
+ mm_create_program(symbollnk symbol z)
+endif()
+add_executable(builtin builtin.cpp libmodman/test/builtin_one.cpp)
+target_link_libraries(builtin libmodman)
+set_property(TARGET builtin PROPERTY COMPILE_DEFINITIONS EXTTYPE=builtin_extension;BUILTIN_MODULE="extension";MM_MODULE_BUILTIN=extension)
+
+# Tests
+add_test(NAME condition COMMAND condition $ two)
+add_test(NAME singleton COMMAND singleton $ one)
+add_test(NAME sorted COMMAND sorted $ two one)
+add_test(NAME symbol COMMAND symbollnk $ two)
+add_test(NAME nosymbol COMMAND symbol $)
+add_test(NAME nosymreq COMMAND symbol $ one)
+add_test(NAME builtin COMMAND builtin)
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/CMakeLists.txt new/libproxy-0.4.3/libproxy/CMakeLists.txt
--- old/libproxy-0.4.2/libproxy/CMakeLists.txt 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/libproxy/CMakeLists.txt 2010-06-07 17:57:23.000000000 +0200
@@ -184,3 +184,9 @@
set_target_properties(libproxy PROPERTIES PREFIX "" VERSION 1.0.0 SOVERSION 1)
install(TARGETS libproxy DESTINATION ${libdir})
install(FILES proxy.h DESTINATION ${includedir})
+
+
+## Tests
+if (BUILD_TESTING)
+ add_subdirectory(test)
+endif(BUILD_TESTING)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/modules/config_gnome.cpp new/libproxy-0.4.3/libproxy/modules/config_gnome.cpp
--- old/libproxy-0.4.2/libproxy/modules/config_gnome.cpp 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/libproxy/modules/config_gnome.cpp 2010-06-07 17:57:23.000000000 +0200
@@ -21,6 +21,8 @@
#include // For select()
#include // For fcntl()
#include // For errno stuff
+#include // For stat()
+#include // For stat()
#include // For pipe(), close(), vfork(), dup(), execl(), _exit()
#include // For kill()
@@ -192,8 +194,8 @@
else if (this->data[PROXY_MODE] == "manual") {
string type, host, port;
bool auth = this->data[PROXY_USE_AUTHENTICATION] == "true";
- string username = this->data[PROXY_AUTH_USER];
- string password = this->data[PROXY_AUTH_PASSWORD];
+ string username = url::encode(this->data[PROXY_AUTH_USER], url::ALLOWED_IN_USERINFO_ELEMENT);
+ string password = url::encode(this->data[PROXY_AUTH_PASSWORD], url::ALLOWED_IN_USERINFO_ELEMENT);
bool same_proxy = this->data[PROXY_SAME_FOR_ALL] == "true";
// If socks is set use it (except when same_proxy is set)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/modules/pacrunner_webkit.cpp new/libproxy-0.4.3/libproxy/modules/pacrunner_webkit.cpp
--- old/libproxy-0.4.2/libproxy/modules/pacrunner_webkit.cpp 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/libproxy/modules/pacrunner_webkit.cpp 2010-06-07 17:57:23.000000000 +0200
@@ -149,6 +149,7 @@
// Run the PAC
tmp = string("FindProxyForURL(\"") + url_.to_string() + string("\", \"") + url_.get_host() + "\");";
str = JSStringCreateWithUTF8CString(tmp.c_str());
+ if (!str) throw bad_alloc();
if (!JSCheckScriptSyntax(this->jsctx, str, NULL, 0, NULL)) goto error;
if (!(val = JSEvaluateScript(this->jsctx, str, NULL, NULL, 1, NULL))) goto error;
if (!JSValueIsString(this->jsctx, val)) goto error;
@@ -158,8 +159,8 @@
return jstr2str(JSValueToStringCopy(this->jsctx, val, NULL), true);
error:
- if (str) JSStringRelease(str);
- throw bad_alloc();
+ JSStringRelease(str);
+ return "";
}
private:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/proxy.cpp new/libproxy-0.4.3/libproxy/proxy.cpp
--- old/libproxy-0.4.2/libproxy/proxy.cpp 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/libproxy/proxy.cpp 2010-06-07 17:57:23.000000000 +0200
@@ -49,6 +49,11 @@
vector<string> get_proxies(string url);
private:
+ void lock();
+ void unlock();
+
+ void _get_proxies(url *realurl, vector<string> &response);
+
#ifdef WIN32
HANDLE mutex;
#else
@@ -116,14 +121,15 @@
#ifdef WIN32
this->mutex = CreateMutex(NULL, false, NULL);
- WaitForSingleObject(this->mutex, INFINITE);
WSADATA wsadata;
WORD vers = MAKEWORD(2, 2);
WSAStartup(vers, &wsadata);
#else
pthread_mutex_init(&this->mutex, NULL);
- pthread_mutex_lock(&this->mutex);
#endif
+
+ lock();
+
this->pac = NULL;
this->pacurl = NULL;
this->wpad = false;
@@ -146,26 +152,21 @@
this->mm.load_dir(module_dir);
this->mm.load_dir(module_dir, false);
-#ifdef WIN32
- ReleaseMutex(this->mutex);
-#else
- pthread_mutex_unlock(&this->mutex);
-#endif
+ unlock();
}
proxy_factory::~proxy_factory() {
-#ifdef WIN32
- WaitForSingleObject(this->mutex, INFINITE);
-#else
- pthread_mutex_lock(&this->mutex);
-#endif
+ lock();
+
if (this->pac) delete this->pac;
if (this->pacurl) delete this->pacurl;
+
+ unlock();
+
#ifdef WIN32
WSACleanup();
ReleaseMutex(this->mutex);
#else
- pthread_mutex_unlock(&this->mutex);
pthread_mutex_destroy(&this->mutex);
#endif
}
@@ -173,6 +174,33 @@
vector<string> proxy_factory::get_proxies(string url_) {
url* realurl = NULL;
+ vector<string> response;
+
+ // Check to make sure our url is valid
+ if (!url::is_valid(url_))
+ goto do_return;
+ realurl = new url(url_);
+
+ lock();
+
+ // Let trap and forward exceptions so we don't deadlock
+ try {
+ _get_proxies(realurl, response);
+ unlock();
+ if (realurl) delete realurl;
+ } catch (exception &e) {
+ unlock();
+ if (realurl) delete realurl;
+ throw e;
+ }
+
+do_return:
+ if (response.size() == 0)
+ response.push_back("direct://");
+ return response;
+}
+
+void proxy_factory::_get_proxies(url *realurl, vector<string> &response) {
url confurl("direct://");
bool ignored = false, invign = false;
string confign;
@@ -180,19 +208,8 @@
vector networks;
vector configs;
vector ignores;
- vector<string> response;
const char* debug = getenv("_PX_DEBUG");
- // Check to make sure our url is valid
- if (!url::is_valid(url_))
- goto do_return;
- realurl = new url(url_);
-
-#ifdef WIN32
- WaitForSingleObject(this->mutex, INFINITE);
-#else
- pthread_mutex_lock(&this->mutex);
-#endif
// Check to see if our network topology has changed...
networks = this->mm.get_extensions();
@@ -249,8 +266,8 @@
}
i = next+1;
}
- if (!ignored && invign) goto do_return;
- if (ignored && !invign) goto do_return;
+ if (!ignored && invign) return;
+ if (ignored && !invign) return;
/* If we have a wpad config */
if (debug) cerr << "Config is: " << confurl.to_string() << endl;
@@ -328,7 +345,7 @@
this->pac = confurl.get_pac();
if (!this->pac) {
if (debug) cerr << "Unable to download PAC!" << endl;
- goto do_return;
+ return;
}
if (debug) cerr << "PAC received!" << endl;
}
@@ -341,7 +358,7 @@
/* No PAC runner found, fall back to direct */
if (pacrunners.size() == 0) {
if (debug) cerr << "Unable to find a required pacrunner!" << endl;
- goto do_return;
+ return;
}
/* Run the PAC, but only try one PACRunner */
@@ -360,23 +377,26 @@
response.clear();
response.push_back(confurl.to_string());
}
+}
- /* Actually return, freeing misc stuff */
- do_return:
+void proxy_factory::lock() {
#ifdef WIN32
- ReleaseMutex(this->mutex);
+ WaitForSingleObject(this->mutex, INFINITE);
#else
- pthread_mutex_unlock(&this->mutex);
+ pthread_mutex_lock(&this->mutex);
#endif
- if (realurl)
- delete realurl;
- if (response.size() == 0)
- response.push_back("direct://");
- return response;
}
+void proxy_factory::unlock() {
+#ifdef WIN32
+ ReleaseMutex(this->mutex);
+#else
+ pthread_mutex_unlock(&this->mutex);
+#endif
}
+};
+
struct pxProxyFactory_ {
libproxy::proxy_factory pf;
};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/test/CMakeLists.txt new/libproxy-0.4.3/libproxy/test/CMakeLists.txt
--- old/libproxy-0.4.2/libproxy/test/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
+++ new/libproxy-0.4.3/libproxy/test/CMakeLists.txt 2010-06-07 17:57:23.000000000 +0200
@@ -0,0 +1,14 @@
+####
+## Libproxy Tests
+####
+
+include_directories(../)
+
+# URL Test
+add_executable(url-test url-test.cpp ../url.cpp)
+add_test(NAME url-test COMMAND url-test)
+
+# URL Encode
+add_executable(url-encode url-encode.cpp ../url.cpp)
+add_test(NAME url-encode COMMAND url-encode)
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/test/url-encode.cpp new/libproxy-0.4.3/libproxy/test/url-encode.cpp
--- old/libproxy-0.4.2/libproxy/test/url-encode.cpp 1970-01-01 01:00:00.000000000 +0100
+++ new/libproxy-0.4.3/libproxy/test/url-encode.cpp 2010-06-07 17:57:23.000000000 +0200
@@ -0,0 +1,29 @@
+#include <cassert>
+#include <iostream>
+#include <string>
+
+
+#include "url.hpp"
+
+using namespace libproxy;
+
+#define test(cond,rtv) _test(#cond, (cond), (rtv))
+void _test (string exp, bool condition, bool &rtv)
+{
+ if (!condition) {
+ cerr << "Failed: " << exp << endl;
+ rtv = false;
+ }
+}
+
+int main()
+{
+ bool rtv = true;
+ string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
+
+ test(url::encode(valid) == valid, rtv);
+ test(url::encode("é") == "%c3%a9", rtv);
+ test(url::encode("+!@#$^\r%", "!#^") == "%2b!%40#%24^%0d%25", rtv);
+
+ return !rtv;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/test/url-test.cpp new/libproxy-0.4.3/libproxy/test/url-test.cpp
--- old/libproxy-0.4.2/libproxy/test/url-test.cpp 1970-01-01 01:00:00.000000000 +0100
+++ new/libproxy-0.4.3/libproxy/test/url-test.cpp 2010-06-07 17:57:23.000000000 +0200
@@ -0,0 +1,129 @@
+#include <cassert>
+#include <iostream>
+#include <sstream>
+#include <string>
+
+
+#include "url.hpp"
+
+using namespace libproxy;
+
+void assert_equal_str (const std::string &what,
+ const std::string &in,
+ const std::string &value,
+ const std::string &ref)
+{
+ if (value != ref)
+ throw logic_error(what + " in URL " + in + " is '"
+ + value + "' instead of '" + ref + "'");
+}
+
+void assert_equal_int (const std::string &what,
+ const std::string &in,
+ int value,
+ int ref)
+{
+ if (value != ref) {
+ ostringstream s;
+ s << what << " in URL " << in << " is "
+ << value << " instead of " << ref;
+ throw logic_error(s.str());
+ }
+}
+
+void try_url (std::string link, bool &rtv,
+ const std::string &scheme,
+ const std::string &user,
+ const std::string &pass,
+ const std::string &host,
+ int port,
+ const std::string &path)
+{
+ try {
+ url u(link);
+
+ assert_equal_str ("Scheme", u.to_string(), u.get_scheme(), scheme);
+ assert_equal_str ("User", u.to_string(), u.get_username(), user);
+ assert_equal_str ("Pass", u.to_string(), u.get_password(), pass);
+ assert_equal_str ("Host", u.to_string(), u.get_host(), host);
+ assert_equal_int ("Port", u.to_string(), u.get_port(), port);
+ assert_equal_str ("Path", u.to_string(), u.get_path(), path);
+ }
+ catch (exception &e) {
+ std::cerr << e.what() << std::endl;
+ rtv = false;
+ }
+}
+
+int main()
+{
+ bool rtv = true;
+
+ try_url ("file:///allo", rtv,
+ "file",
+ "", "",
+ "", 0,
+ "/allo");
+
+ try_url ("http://test.com", rtv,
+ "http",
+ "", "",
+ "test.com", 80,
+ "");
+
+ try_url ("http://test.com/", rtv,
+ "http",
+ "", "",
+ "test.com", 80,
+ "/");
+
+ try_url ("http://test.com#", rtv,
+ "http",
+ "", "",
+ "test.com", 80,
+ "");
+
+ try_url ("http://test.com?", rtv,
+ "http",
+ "", "",
+ "test.com", 80,
+ "");
+
+ try_url ("http://nicolas@test.com", rtv,
+ "http",
+ "nicolas", "",
+ "test.com", 80,
+ "");
+
+ try_url ("http://nicolas:@test.com", rtv,
+ "http",
+ "nicolas", "",
+ "test.com", 80,
+ "");
+
+ try_url ("http://nicolas:secret@test.com", rtv,
+ "http",
+ "nicolas", "secret",
+ "test.com", 80,
+ "");
+
+ try_url ("http://:secret@test.com", rtv,
+ "http",
+ "", "secret",
+ "test.com", 80,
+ "");
+
+ try_url ("http+ssh://:secret@test.com", rtv,
+ "http+ssh",
+ "", "secret",
+ "test.com", 22,
+ "");
+
+ try_url ("HtTp://TeSt.CoM/ALLO", rtv,
+ "http",
+ "", "",
+ "test.com", 80,
+ "/ALLO");
+
+ return !rtv;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/url.cpp new/libproxy-0.4.3/libproxy/url.cpp
--- old/libproxy-0.4.2/libproxy/url.cpp 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/libproxy/url.cpp 2010-06-07 17:57:23.000000000 +0200
@@ -2,6 +2,9 @@
* libproxy - A library for proxy configuration
* Copyright (C) 2006 Nathaniel McCallum
*
+ * Based on work found in GLib GIO:
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -15,6 +18,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
******************************************************************************/
#ifdef WIN32
#include
@@ -28,6 +32,7 @@
#include <cstdio> // For sscanf()
#include <cstdlib> // For atoi()
#include // For stat()
+#include <algorithm> // For transform()
#ifdef WIN32
#include
@@ -51,10 +56,24 @@
// This is the maximum pac size (to avoid memory attacks)
#define PAC_MAX_SIZE 102400
+const string url::GENERIC_DELIMITERS(":/?#[]@");
+const string url::SUBCOMPONENT_DELIMITERS("!$&'()*+,;=");
+const string url::ALLOWED_IN_USERINFO_ELEMENT(url::SUBCOMPONENT_DELIMITERS);
+const string url::ALLOWED_IN_USERINFO(url::ALLOWED_IN_USERINFO_ELEMENT + ":");
+const string url::ALLOWED_IN_PATH_ELEMENT(url::SUBCOMPONENT_DELIMITERS + ":@");
+const string url::ALLOWED_IN_PATH(url::ALLOWED_IN_PATH_ELEMENT + "/");
+
static inline int get_default_port(string scheme) {
- struct servent *serv;
- if ((serv = getservbyname(scheme.c_str(), NULL))) return ntohs(serv->s_port);
- return 0;
+ struct servent *serv;
+ size_t plus = scheme.find('+');
+
+ if (plus != string::npos)
+ scheme = scheme.substr(plus + 1);
+
+ if ((serv = getservbyname(scheme.c_str(), NULL)))
+ return ntohs(serv->s_port);
+
+ return 0;
}
template <class T>
@@ -77,167 +96,217 @@
}
bool url::is_valid(const string url_) {
- url* tmp;
- try { tmp = new url(url_); }
- catch (parse_error&) { return false; }
- delete tmp;
- return true;
-}
-
-url::url(const string url) throw(parse_error, logic_error) {
- char *schm = new char[url.size()];
- char *auth = new char[url.size()];
- char *host = new char[url.size()];
- char *path = new char[url.size()];
- bool port_specified = false;
- bool auth_specified = false;
- bool pass_specified = false;
- this->ips = NULL;
-
- // Break apart our url into 4 sections: scheme, auth (user/pass), host and path
- // We'll do further parsing of auth and host a bit later
- // NOTE: reset the unused variable after each scan or we get bleed-through
- if (sscanf(url.c_str(), "%[^:]://%[^@]@%[^/]/%s", schm, auth, host, path) != 4 && !((*path = '\0')) && // URL with auth, host and path
- sscanf(url.c_str(), "%[^:]://%[^@]@%[^/]", schm, auth, host) != 3 && !((*auth = '\0')) && // URL with auth, host
- sscanf(url.c_str(), "%[^:]://%[^/]/%s", schm, host, path) != 3 && !((*path = '\0')) && // URL with host, path
- sscanf(url.c_str(), "%[^:]://%[^/]", schm, host) != 2 && !((*host = '\0')) && // URL with host
- !(sscanf(url.c_str(), "%[^:]://%s", schm, path) == 2 && string("file") == schm) && !((*path = '\0')) && // URL with path (ex: file:///foo)
- !(sscanf(url.c_str(), "%[^:]://", schm) == 1 && (string("direct") == schm || string("wpad") == schm))) // URL with scheme-only (ex: wpad://, direct://)
- {
- delete[] schm;
- delete[] auth;
- delete[] host;
- delete[] path;
- throw parse_error("Invalid URL: " + url);
+ bool rtv = true;
+
+ try {
+ url url(url_);
+ } catch (parse_error&) {
+ rtv = false;
}
- // Set scheme and path
- this->scheme = schm;
- this->path = *path ? string("/") + path : "";
- *schm = '\0';
- *path = '\0';
-
- // Parse auth further
- if (*auth) {
- auth_specified = true;
- this->user = auth;
- if (string(auth).find(":") != string:: npos) {
- pass_specified = true;
- this->pass = this->user.substr(this->user.find(":")+1);
- this->user = this->user.substr(0, this->user.find(":"));
- }
- *auth = '\0';
+ return rtv;
+}
+
+string url::encode(const string &data, const string &valid_reserved) {
+ ostringstream encoded;
+ for (int i=0; data[i]; i++) {
+ if (isalnum(data[i])
+ || valid_reserved.find(data[i]) != string::npos
+ || string("-._~").find(data[i]) != string::npos)
+ encoded << data[i];
+ else
+ encoded << '%'
+ << ((unsigned char)data[i] < 16 ? "0" : "")
+ << hex << (((int)data[i]) & 0xff);
}
+ return encoded.str();
+}
- // Parse host further. Basically, we're looking for a port.
- if (*host) {
- this->port = get_default_port(this->scheme);
- if (this->scheme.find('+') != this->scheme.npos)
- this->port = get_default_port(this->scheme.substr(this->scheme.find('+')+1));
-
- int hostlen = strlen(host);
- for (int i=hostlen-1 ; i >= 0 ; i--) {
- if (host[i] >= '0' && host[i] <= '9') continue; // Still might be a port
- if (host[i] != ':' || hostlen - 1 == i) break; // Definitely not a port
- if (sscanf(host + i + 1, "%hu", &this->port) != 1) break; // Parse fail, should never happen
- port_specified = true;
- host[i] = '\0'; // Terminate at the port ':'
- break;
+url::url(const string url) throw(parse_error)
+ : m_orig(url), m_port(0), m_ips(NULL) {
+ size_t idx = 0;
+ size_t hier_part_start, hier_part_end;
+ size_t path_start, path_end;
+ string hier_part;
+
+ /* From RFC 3986 Decodes:
+ * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
+ */
+
+ idx = 0;
+
+ /* Decode scheme:
+ * scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+ */
+
+ if (!isalpha(url[idx]))
+ throw parse_error("Invalid URL: " + url);
+
+ while (1) {
+ char c = url[idx++];
+
+ if (c == ':') break;
+
+ if (!(isalnum(c) ||
+ c == '+' ||
+ c == '-' ||
+ c == '.'))
+ throw parse_error("Invalid URL: " + url);
+ }
+
+ m_scheme = url.substr(0, idx - 1);
+ transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(), ::tolower);
+
+ hier_part_start = idx;
+ hier_part_end = url.find('?', idx);
+ if (hier_part_end == string::npos)
+ hier_part_end = url.find('#', idx);
+
+ hier_part = url.substr(hier_part_start,
+ hier_part_end == string::npos ?
+ string::npos : hier_part_end - hier_part_start);
+
+ /* 3:
+ * hier-part = "//" authority path-abempty
+ * / path-absolute
+ * / path-rootless
+ * / path-empty
+ */
+
+ if (hier_part[0] == '/' && hier_part[1] == '/') {
+ size_t authority_start, authority_end;
+ size_t userinfo_start, userinfo_end;
+ size_t host_start, host_end;
+
+ authority_start = 2;
+ /* authority is always followed by / or nothing */
+ authority_end = hier_part.find('/', authority_start);
+ path_start = authority_end;
+
+ /* 3.2:
+ * authority = [ userinfo "@" ] host [ ":" port ]
+ */
+
+ /* Get user and password */
+ userinfo_start = authority_start;
+ userinfo_end = hier_part.find('@', authority_start);
+ if (userinfo_end != string::npos) {
+ size_t user_end;
+
+ user_end = hier_part.rfind(':', userinfo_end);
+ if (user_end == string::npos)
+ user_end = userinfo_end;
+ else
+ m_pass = hier_part.substr(user_end + 1, userinfo_end - (user_end + 1));
+
+ m_user = hier_part.substr(userinfo_start, user_end - userinfo_start);
}
- this->host = host;
- *host = '\0';
+ /* Get hostname */
+ if (userinfo_end == string::npos)
+ host_start = authority_start;
+ else
+ host_start = userinfo_end + 1;
+
+ /* Check for IPv6 IP */
+ if (hier_part[host_start] == '[') {
+ host_end = hier_part.find(']', host_start);
+ if (host_end == string::npos)
+ throw parse_error("Invalid URL: " + url);
+ host_end++;
+ if (hier_part[host_end] == '\0')
+ host_end = string::npos;
+ } else {
+ host_end = hier_part.find(':', host_start);
+ }
+
+ /* If not port, host ends where path starts */
+ if (host_end == string::npos)
+ host_end = path_start;
+
+ m_host = hier_part.substr(host_start, host_end - host_start);
+ transform(m_host.begin(), m_host.end(), m_host.begin(), ::tolower);
+
+ /* Get port */
+ m_port = get_default_port(m_scheme);
+
+ if (hier_part[host_end] == ':') {
+ size_t port_start = host_end + 1;
+ m_port = atoi(hier_part.c_str() + port_start);
+ }
+ } else {
+ path_start = hier_part_start;
}
- // Cleanup
- delete[] schm;
- delete[] auth;
- delete[] host;
- delete[] path;
-
- // Verify by re-assembly
- if (auth_specified)
- if (pass_specified)
- this->orig = this->scheme + "://" + this->user + ":" + this->pass + "@" + this->host;
+ /* Get path */
+ if (path_start != string::npos)
+ {
+ path_end = hier_part_end;
+ if (path_end == string::npos)
+ m_path = hier_part.substr(path_start);
else
- this->orig = this->scheme + "://" + this->user + "@" + this->host;
- else
- this->orig = this->scheme + "://" + this->host;
- if (port_specified)
- this->orig = this->orig + ":" + to_string_<int>(this->port) + this->path;
- else
- this->orig = this->orig + this->path;
- if (this->orig != url)
- throw logic_error("Re-assembly failed!");
+ m_path = hier_part.substr(path_start, path_end - path_start);
+ }
}
-url::url(const url &url) {
- this->ips = NULL;
+url::url(const url &url) : m_ips(NULL) {
*this = url;
}
url::~url() {
- if (this->ips) {
- for (int i=0 ; this->ips[i] ; i++)
- delete this->ips[i];
- delete this->ips;
- }
+ empty_cache();
}
bool url::operator==(const url& url) const {
- return this->orig == url.to_string();
+ return m_orig == url.to_string();
}
url& url::operator=(const url& url) {
- int i=0;
-
// Ensure these aren't the same objects
if (&url == this)
return *this;
- this->host = url.host;
- this->orig = url.orig;
- this->pass = url.pass;
- this->path = url.path;
- this->port = url.port;
- this->scheme = url.scheme;
- this->user = url.user;
+ m_host = url.m_host;
+ m_orig = url.m_orig;
+ m_pass = url.m_pass;
+ m_path = url.m_path;
+ m_port = url.m_port;
+ m_scheme = url.m_scheme;
+ m_user = url.m_user;
- if (this->ips) {
- // Free any existing ip cache
- for (i=0 ; this->ips[i] ; i++)
- delete this->ips[i];
- delete this->ips;
- this->ips = NULL;
- }
+ empty_cache();
+
+ if (url.m_ips) {
+ int i;
- if (url.ips) {
// Copy the new ip cache
- for (i=0 ; url.ips[i] ; i++) {};
- this->ips = new sockaddr*[i];
- for (i=0 ; url.ips[i] ; i++)
- this->ips[i] = copyaddr(*url.ips[i]);
+ for (i=0 ; url.m_ips[i] ; i++) {};
+ m_ips = new sockaddr*[i];
+ for (i=0 ; url.m_ips[i] ; i++)
+ m_ips[i] = copyaddr(*url.m_ips[i]);
}
+
return *this;
}
url& url::operator=(string strurl) throw (parse_error) {
- url* tmp = new url(strurl);
- *this = *tmp;
- delete tmp;
+ url tmp(strurl);
+ *this = tmp;
return *this;
}
string url::get_host() const {
- return this->host;
+ return m_host;
}
sockaddr const* const* url::get_ips(bool usedns) {
// Check the cache
- if (this->ips) return this->ips;
+ if (m_ips)
+ return m_ips;
// Check without DNS first
- if (usedns && this->get_ips(false)) return this->ips;
+ if (usedns && get_ips(false))
+ return m_ips;
// Check DNS for IPs
struct addrinfo* info;
@@ -247,7 +316,7 @@
flags.ai_socktype = 0;
flags.ai_protocol = 0;
flags.ai_flags = AI_NUMERICHOST;
- if (!getaddrinfo(this->host.c_str(), NULL, usedns ? NULL : &flags, &info)) {
+ if (!getaddrinfo(m_host.c_str(), NULL, usedns ? NULL : &flags, &info)) {
struct addrinfo* first = info;
unsigned int i = 0;
@@ -257,23 +326,23 @@
// Return NULL if no IPs found
if (i == 0)
- return this->ips = NULL;
+ return m_ips = NULL;
// Create our array since we actually have a result
- this->ips = new sockaddr*[++i];
- memset(this->ips, '\0', sizeof(sockaddr*)*i);
+ m_ips = new sockaddr*[++i];
+ memset(m_ips, '\0', sizeof(sockaddr*)*i);
- // Copy the sockaddr's into this->ips
+ // Copy the sockaddr's into m_ips
for (i = 0, info = first ; info ; info = info->ai_next) {
if (info->ai_addr->sa_family == AF_INET || info->ai_addr->sa_family == AF_INET6) {
- this->ips[i] = copyaddr(*(info->ai_addr));
- if (!this->ips[i]) break;
- ((sockaddr_in **) this->ips)[i++]->sin_port = htons(this->port);
+ m_ips[i] = copyaddr(*(info->ai_addr));
+ if (!m_ips[i]) break;
+ ((sockaddr_in **) m_ips)[i++]->sin_port = htons(m_port);
}
}
freeaddrinfo(first);
- return this->ips;
+ return m_ips;
}
// No addresses found
@@ -281,27 +350,27 @@
}
string url::get_password() const {
- return this->pass;
+ return m_pass;
}
string url::get_path() const {
- return this->path;
+ return m_path;
}
uint16_t url::get_port() const {
- return this->port;
+ return m_port;
}
string url::get_scheme() const {
- return this->scheme;
+ return m_scheme;
}
string url::get_username() const {
- return this->user;
+ return m_user;
}
string url::to_string() const {
- return this->orig;
+ return m_orig;
}
static inline string recvline(int fd) {
@@ -309,7 +378,10 @@
// If we don't get a character, return empty string.
// If we are at the end of the line, return empty string.
char c = '\0';
- if (recv(fd, &c, 1, 0) != 1 || c == '\n') return "";
+
+ if (recv(fd, &c, 1, 0) != 1 || c == '\n')
+ return "";
+
return string(1, c) + recvline(fd);
}
@@ -321,9 +393,9 @@
string request;
// In case of a file:// url we open the file and read it
- if (this->scheme == "file" || this->scheme == "pac+file") {
+ if (m_scheme == "file" || m_scheme == "pac+file") {
struct stat st;
- if ((sock = ::open(this->path.c_str(), O_RDONLY)) < 0)
+ if ((sock = ::open(m_path.c_str(), O_RDONLY)) < 0)
return NULL;
if (!fstat(sock, &st) && pfsize(st) < PAC_MAX_SIZE) {
buffer = new char[pfsize(st)+1];
@@ -336,20 +408,20 @@
}
// DNS lookup of host
- if (!this->get_ips(true))
+ if (!get_ips(true))
return NULL;
// Iterate through each IP trying to make a connection
// Stop at the first one
- for (int i=0 ; this->ips[i] ; i++) {
- sock = socket(this->ips[i]->sa_family, SOCK_STREAM, 0);
+ for (int i=0 ; m_ips[i] ; i++) {
+ sock = socket(m_ips[i]->sa_family, SOCK_STREAM, 0);
if (sock < 0) continue;
- if (this->ips[i]->sa_family == AF_INET &&
- !connect(sock, this->ips[i], sizeof(struct sockaddr_in)))
+ if (m_ips[i]->sa_family == AF_INET &&
+ !connect(sock, m_ips[i], sizeof(struct sockaddr_in)))
break;
- else if (this->ips[i]->sa_family == AF_INET6 &&
- !connect(sock, this->ips[i], sizeof(struct sockaddr_in6)))
+ else if (m_ips[i]->sa_family == AF_INET6 &&
+ !connect(sock, m_ips[i], sizeof(struct sockaddr_in6)))
break;
close(sock);
@@ -360,8 +432,8 @@
if (sock < 0) return NULL;
// Build the request string
- request = "GET " + this->path + " HTTP/1.1\r\n";
- request += "Host: " + this->host + "\r\n";
+ request = "GET " + m_path + " HTTP/1.1\r\n";
+ request += "Host: " + m_host + "\r\n";
request += "Accept: " + string(PAC_MIME_TYPE) + "\r\n";
request += "Connection: close\r\n";
request += "\r\n";
@@ -430,3 +502,14 @@
shutdown(sock, SHUT_RDWR);
return buffer;
}
+
+void url::empty_cache()
+{
+ if (m_ips) {
+ // Free any existing ip cache
+ for (int i=0 ; m_ips[i] ; i++)
+ delete m_ips[i];
+ delete[] m_ips;
+ m_ips = NULL;
+ }
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libproxy-0.4.2/libproxy/url.hpp new/libproxy-0.4.3/libproxy/url.hpp
--- old/libproxy-0.4.2/libproxy/url.hpp 2010-05-19 20:01:34.000000000 +0200
+++ new/libproxy-0.4.3/libproxy/url.hpp 2010-06-07 17:57:23.000000000 +0200
@@ -38,11 +38,19 @@
class DLL_PUBLIC url {
public:
+ static const string ALLOWED_IN_PATH;
+ static const string ALLOWED_IN_PATH_ELEMENT;
+ static const string ALLOWED_IN_USERINFO;
+ static const string ALLOWED_IN_USERINFO_ELEMENT;
+ static const string GENERIC_DELIMITERS;
+ static const string SUBCOMPONENT_DELIMITERS;
+
static bool is_valid(const string url);
+ static string encode(const string &data, const string &valid_reserved = "");
~url();
url(const url& url);
- url(string url) throw (parse_error, logic_error);
+ url(string url) throw (parse_error);
bool operator==(const url& url) const;
url& operator=(const url& url);
url& operator=(string url) throw (parse_error);
@@ -58,14 +66,16 @@
char* get_pac(); // Allocated, must free. NULL on error.
private:
- string host;
- sockaddr** ips;
- string pass;
- string path;
- uint16_t port;
- string scheme;
- string orig;
- string user;
+ void empty_cache();
+
+ string m_orig;
+ string m_scheme;
+ string m_user;
+ string m_pass;
+ string m_host;
+ uint16_t m_port;
+ string m_path;
+ sockaddr** m_ips;
};
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org