Juan Lang : winhttp: Strip scheme from http_proxy environment variable.
Alexandre Julliard
julliard at winehq.org
Wed Jul 22 09:33:37 CDT 2009
Module: wine
Branch: master
Commit: 68fdc5cb2e8a17cebfcd2e3d0b02c8033612db0a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=68fdc5cb2e8a17cebfcd2e3d0b02c8033612db0a
Author: Juan Lang <juan.lang at gmail.com>
Date: Tue Jul 21 11:36:52 2009 -0700
winhttp: Strip scheme from http_proxy environment variable.
---
dlls/winhttp/session.c | 47 ++++++++++++++++++++++++++++++++++++-----------
1 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 227354d..2ed53b0 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -929,19 +929,44 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
}
else if ((envproxy = getenv( "http_proxy" )))
{
- WCHAR *envproxyW;
- int len;
+ char *colon, *http_proxy;
- len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 );
- if ((envproxyW = GlobalAlloc( 0, len * sizeof(WCHAR))))
+ if ((colon = strchr( envproxy, ':' )))
{
- MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len );
- direct = FALSE;
- info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
- info->lpszProxy = envproxyW;
- info->lpszProxyBypass = NULL;
- TRACE("http proxy (from environment) = %s\n",
- debugstr_w(info->lpszProxy));
+ if (*(colon + 1) == '/' && *(colon + 2) == '/')
+ {
+ static const char http[] = "http://";
+
+ /* It's a scheme, check that it's http */
+ if (!strncmp( envproxy, http, strlen( http ) ))
+ http_proxy = envproxy + strlen( http );
+ else
+ {
+ WARN("unsupported scheme in $http_proxy: %s\n", envproxy);
+ http_proxy = NULL;
+ }
+ }
+ else
+ http_proxy = envproxy;
+ }
+ else
+ http_proxy = envproxy;
+ if (http_proxy)
+ {
+ WCHAR *http_proxyW;
+ int len;
+
+ len = MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, NULL, 0 );
+ if ((http_proxyW = GlobalAlloc( 0, len * sizeof(WCHAR))))
+ {
+ MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, http_proxyW, len );
+ direct = FALSE;
+ info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
+ info->lpszProxy = http_proxyW;
+ info->lpszProxyBypass = NULL;
+ TRACE("http proxy (from environment) = %s\n",
+ debugstr_w(info->lpszProxy));
+ }
}
}
if (direct)
More information about the wine-cvs
mailing list