[3/3] wininet: Parse user and password for proxy authentication

André Hentschel nerv at dawncrow.de
Mon Aug 22 14:31:54 CDT 2011


---
 dlls/wininet/internet.c |   43 ++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 3d85dd7..cf555c7 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -621,9 +621,46 @@ static BOOL INTERNET_ConfigureProxy( appinfo_t *lpwai )
 
     if (wpi.proxyEnabled)
     {
-        lpwai->accessType = INTERNET_OPEN_TYPE_PROXY;
-        lpwai->proxy = wpi.proxy;
-        return TRUE;
+        WCHAR proxyurl[INTERNET_MAX_URL_LENGTH];
+        WCHAR username[INTERNET_MAX_USER_NAME_LENGTH];
+        WCHAR password[INTERNET_MAX_PASSWORD_LENGTH];
+        WCHAR hostname[INTERNET_MAX_HOST_NAME_LENGTH];
+        URL_COMPONENTSW UrlComponents;
+
+        UrlComponents.dwStructSize = sizeof UrlComponents;
+        UrlComponents.dwSchemeLength = 0;
+        UrlComponents.lpszHostName = hostname;
+        UrlComponents.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH;
+        UrlComponents.lpszUserName = username;
+        UrlComponents.dwUserNameLength = INTERNET_MAX_USER_NAME_LENGTH;
+        UrlComponents.lpszPassword = password;
+        UrlComponents.dwPasswordLength = INTERNET_MAX_PASSWORD_LENGTH;
+        UrlComponents.dwExtraInfoLength = 0;
+
+        if(InternetCrackUrlW(wpi.proxy, 0, 0, &UrlComponents))
+        {
+            static const WCHAR szFormat[] = { 'h','t','t','p',':','/','/','%','s',':','%','u',0 };
+
+            if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER)
+                UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
+            sprintfW(proxyurl, szFormat, hostname, UrlComponents.nPort);
+
+            lpwai->accessType = INTERNET_OPEN_TYPE_PROXY;
+            lpwai->proxy = heap_strdupW(proxyurl);
+            if (UrlComponents.dwUserNameLength)
+            {
+                lpwai->proxyUsername = heap_strdupW(UrlComponents.lpszUserName);
+                lpwai->proxyPassword = heap_strdupW(UrlComponents.lpszPassword);
+            }
+
+            TRACE("http proxy = %s\n", debugstr_w(lpwai->proxy));
+            return TRUE;
+        }
+        else
+        {
+            TRACE("Failed to parse proxy: %s\n", debugstr_w(wpi.proxy));
+            lpwai->proxy = NULL;
+        }
     }
 
     lpwai->accessType = INTERNET_OPEN_TYPE_DIRECT;
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list