From cadad89d106186a9d0377607096a58677496ec50 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 28 Nov 2019 08:49:07 +0100 Subject: [PATCH] wininet: Handle http_proxy variable entirely in Unicode. Signed-off-by: Alexandre Julliard --- dlls/wininet/internet.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index c7e88c83ff3..16dc200c137 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -541,7 +541,7 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) { HKEY key; DWORD type, len; - LPCSTR envproxy; + const WCHAR *envproxy; LONG ret; memset( lpwpi, 0, sizeof(*lpwpi) ); @@ -573,7 +573,7 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) } } - if (!(envproxy = getenv( "http_proxy" )) || lpwpi->proxyEnabled) + if (!(envproxy = _wgetenv( L"http_proxy" )) || lpwpi->proxyEnabled) { /* figure out how much memory the proxy setting takes */ if (!RegQueryValueExW( key, szProxyServer, NULL, &type, NULL, &len ) && len && (type == REG_SZ)) @@ -615,18 +615,8 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) } else if (envproxy) { - WCHAR *envproxyW; - - len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 ); - if (!(envproxyW = heap_alloc(len * sizeof(WCHAR)))) - { - RegCloseKey( key ); - return ERROR_OUTOFMEMORY; - } - MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len ); - FreeProxyInfo( lpwpi ); - if (parse_proxy_url( lpwpi, envproxyW )) + if (parse_proxy_url( lpwpi, envproxy )) { TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi->proxy)); lpwpi->proxyEnabled = 1; @@ -634,19 +624,18 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) } else { - WARN("failed to parse http_proxy value %s\n", debugstr_w(envproxyW)); + WARN("failed to parse http_proxy value %s\n", debugstr_w(envproxy)); lpwpi->proxyEnabled = 0; lpwpi->proxy = NULL; lpwpi->proxyBypass = NULL; } - heap_free( envproxyW ); } if (lpwpi->proxyEnabled) { TRACE("Proxy is enabled.\n"); - if (!(envproxy = getenv( "no_proxy" ))) + if (!(envproxy = _wgetenv( L"no_proxy" ))) { /* figure out how much memory the proxy setting takes */ if (!RegQueryValueExW( key, szProxyOverride, NULL, &type, NULL, &len ) && len && (type == REG_SZ)) @@ -677,13 +666,12 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) { WCHAR *envproxyW; - len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 ); - if (!(envproxyW = heap_alloc(len * sizeof(WCHAR)))) + if (!(envproxyW = heap_alloc(lstrlenW(envproxy) * sizeof(WCHAR)))) { RegCloseKey( key ); return ERROR_OUTOFMEMORY; } - MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len ); + lstrcpyW( envproxyW, envproxy ); heap_free( lpwpi->proxyBypass ); lpwpi->proxyBypass = envproxyW;