[PATCH] winhttp: No need to search for proxy for localhost urls

Jon Doron arilou at gmail.com
Thu May 20 01:01:07 CDT 2021


This will resolve the bug:
https://bugs.winehq.org/show_bug.cgi?id=43011

Signed-off-by: Jon Doron <arilou at gmail.com>
---
 dlls/winhttp/session.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index f052c3c569c..4a1a6803acb 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -1872,6 +1872,21 @@ static BOOL run_script( char *script, DWORD size, const WCHAR *url, WINHTTP_PROX
     return ret;
 }
 
+static BOOL is_localhost( LPCWSTR url )
+{
+    LPCWSTR scheme;
+
+    scheme = wcsstr(url, L"://");
+    if (!scheme)
+    {
+        return FALSE;
+    }
+
+    return !wcsnicmp( scheme, L"://127.0.0.1", _countof(L"://127.0.0.1") - 1 ) ||
+           !wcsnicmp( scheme, L"://localhost", _countof(L"://localhost") - 1) ||
+           !wcsnicmp( scheme, L"://::1", _countof(L"://::1") - 1 );
+}
+
 /***********************************************************************
  *          WinHttpGetProxyForUrl (winhttp.@)
  */
@@ -1908,6 +1923,14 @@ BOOL WINAPI WinHttpGetProxyForUrl( HINTERNET hsession, LPCWSTR url, WINHTTP_AUTO
         SetLastError( ERROR_INVALID_PARAMETER );
         return FALSE;
     }
+
+    if (is_localhost(url))
+    {
+        release_object( &session->hdr );
+        SetLastError( ERROR_INVALID_PARAMETER );
+        return FALSE;
+    }
+
     if (options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT &&
         !WinHttpDetectAutoProxyConfigUrl( options->dwAutoDetectFlags, &detected_pac_url ))
         goto done;
-- 
2.31.1




More information about the wine-devel mailing list