Module: wine Branch: refs/heads/master Commit: d3047aaebabed5f04b2809a5069f50113d1deac4 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=d3047aaebabed5f04b2809a5...
Author: Robert Shearman rob@codeweavers.com Date: Thu Mar 9 15:18:24 2006 +0000
wininet: If necessary, add a slash between the hostname and path in InternetCreateUrlW.
---
dlls/wininet/internet.c | 11 +++++++++++ dlls/wininet/tests/http.c | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 5beb622..5930ea5 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -3781,7 +3781,11 @@ static BOOL calc_url_length(LPURL_COMPON }
if (lpUrlComponents->lpszHostName) + { *lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, HostName); + if (lpUrlComponents->lpszUrlPath && *lpUrlComponents->lpszUrlPath != '/') + (*lpdwUrlLength)++; /* '/' */ + }
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort)) { @@ -4011,6 +4015,13 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COM dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, HostName); memcpy(lpszUrl, lpUrlComponents->lpszHostName, dwLen * sizeof(WCHAR)); lpszUrl += dwLen; + + /* add slash between hostname and path if necessary */ + if (lpUrlComponents->lpszUrlPath && *lpUrlComponents->lpszUrlPath != '/') + { + *lpszUrl = '/'; + lpszUrl++; + } }
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort)) diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 90a972c..a4b66eb 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -48,6 +48,7 @@ #define CREATE_URL7 "http://username:password@www.winehq.org:42/site/about" #define CREATE_URL8 "https://username:password@www.winehq.org/site/about" #define CREATE_URL9 "about:blank" +#define CREATE_URL10 "about://host/blank"
static HANDLE hCompleteEvent;
@@ -1109,6 +1110,7 @@ static void InternetCreateUrlA_test(void urlComp.lpszUrlPath = "blank"; urlComp.dwUrlPathLength = 5; len = strlen(CREATE_URL9); + len++; /* work around bug in native wininet */ szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len); ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len); ok(ret, "Expected success\n"); @@ -1116,6 +1118,21 @@ static void InternetCreateUrlA_test(void ok(!strcmp(szUrl, CREATE_URL9), "Expected %s, got %s\n", CREATE_URL9, szUrl);
HeapFree(GetProcessHeap(), 0, szUrl); + + memset(&urlComp, 0, sizeof(urlComp)); + urlComp.dwStructSize = sizeof(URL_COMPONENTS); + urlComp.lpszScheme = "about"; + urlComp.lpszHostName = "host"; + urlComp.lpszUrlPath = "blank"; + len = strlen(CREATE_URL10); + len++; /* work around bug in native wininet */ + szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len); + ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len); + ok(ret, "Expected success\n"); + ok(len == strlen(CREATE_URL10), "Expected len %d, got %ld\n", strlen(CREATE_URL9), len); + ok(!strcmp(szUrl, CREATE_URL10), "Expected %s, got %s\n", CREATE_URL9, szUrl); + + HeapFree(GetProcessHeap(), 0, szUrl); }
static void HttpSendRequestEx_test(void)