Robert Shearman : wininet: Fix redirects with relative URIs instead of absolute URIs.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 9 16:06:05 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 0590025e3c223602783273f3d1b054f44568d66d
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=0590025e3c223602783273f3d1b054f44568d66d

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu Mar  9 15:11:59 2006 +0000

wininet: Fix redirects with relative URIs instead of absolute URIs.

---

 dlls/wininet/http.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 54 insertions(+), 1 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 495b0b5..156bc64 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -1980,6 +1980,55 @@ static BOOL HTTP_HandleRedirect(LPWININE
         WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
         static const WCHAR szHttp[] = {'h','t','t','p',0};
         static const WCHAR szHttps[] = {'h','t','t','p','s',0};
+        DWORD url_length = 0;
+        LPWSTR orig_url;
+        LPWSTR combined_url;
+
+        urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
+        urlComponents.lpszScheme = (lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE) ? (LPWSTR)szHttps : (LPWSTR)szHttp;
+        urlComponents.dwSchemeLength = 0;
+        urlComponents.lpszHostName = lpwhs->lpszHostName;
+        urlComponents.dwHostNameLength = 0;
+        urlComponents.nPort = lpwhs->nHostPort;
+        urlComponents.lpszUserName = lpwhs->lpszUserName;
+        urlComponents.dwUserNameLength = 0;
+        urlComponents.lpszPassword = NULL;
+        urlComponents.dwPasswordLength = 0;
+        urlComponents.lpszUrlPath = lpwhr->lpszPath;
+        urlComponents.dwUrlPathLength = 0;
+        urlComponents.lpszExtraInfo = NULL;
+        urlComponents.dwExtraInfoLength = 0;
+
+        if (!InternetCreateUrlW(&urlComponents, 0, NULL, &url_length) &&
+            (GetLastError() != ERROR_INSUFFICIENT_BUFFER))
+            return FALSE;
+
+        url_length++; /* for nul terminating character */
+        orig_url = HeapAlloc(GetProcessHeap(), 0, url_length * sizeof(WCHAR));
+
+        if (!InternetCreateUrlW(&urlComponents, 0, orig_url, &url_length))
+        {
+            HeapFree(GetProcessHeap(), 0, orig_url);
+            return FALSE;
+        }
+
+        url_length = 0;
+        if (!InternetCombineUrlW(orig_url, lpszUrl, NULL, &url_length, ICU_ENCODE_SPACES_ONLY) &&
+            (GetLastError() != ERROR_INSUFFICIENT_BUFFER))
+        {
+            HeapFree(GetProcessHeap(), 0, orig_url);
+            return FALSE;
+        }
+        combined_url = HeapAlloc(GetProcessHeap(), 0, url_length * sizeof(WCHAR));
+
+        if (!InternetCombineUrlW(orig_url, lpszUrl, combined_url, &url_length, ICU_ENCODE_SPACES_ONLY))
+        {
+            HeapFree(GetProcessHeap(), 0, orig_url);
+            HeapFree(GetProcessHeap(), 0, combined_url);
+            return FALSE;
+        }
+        HeapFree(GetProcessHeap(), 0, orig_url);
+
         userName[0] = 0;
         hostName[0] = 0;
         protocol[0] = 0;
@@ -1997,8 +2046,12 @@ static BOOL HTTP_HandleRedirect(LPWININE
         urlComponents.dwUrlPathLength = 2048;
         urlComponents.lpszExtraInfo = NULL;
         urlComponents.dwExtraInfoLength = 0;
-        if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents))
+        if(!InternetCrackUrlW(combined_url, strlenW(combined_url), 0, &urlComponents))
+        {
+            HeapFree(GetProcessHeap(), 0, combined_url);
             return FALSE;
+        }
+        HeapFree(GetProcessHeap(), 0, combined_url);
 
         if (!strncmpW(szHttp, urlComponents.lpszScheme, strlenW(szHttp)) &&
             (lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE))




More information about the wine-cvs mailing list