Commit b0fcaf9d authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

wininet: Further InternetCreateFileW fixes.

- Add the slash after the port number. - Only add the port number if the host name is present.
parent d3047aae
......@@ -3783,20 +3783,23 @@ static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents,
if (lpUrlComponents->lpszHostName)
{
*lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, HostName);
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
{
char szPort[MAX_WORD_DIGITS];
sprintf(szPort, "%d", lpUrlComponents->nPort);
*lpdwUrlLength += strlen(szPort);
*lpdwUrlLength += strlen(":");
}
if (lpUrlComponents->lpszUrlPath && *lpUrlComponents->lpszUrlPath != '/')
(*lpdwUrlLength)++; /* '/' */
}
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
{
char szPort[MAX_WORD_DIGITS];
sprintf(szPort, "%d", lpUrlComponents->nPort);
*lpdwUrlLength += strlen(szPort);
*lpdwUrlLength += strlen(":");
}
if (lpUrlComponents->lpszUrlPath)
*lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, UrlPath);
*lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, UrlPath);
return TRUE;
}
......@@ -4016,6 +4019,18 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
memcpy(lpszUrl, lpUrlComponents->lpszHostName, dwLen * sizeof(WCHAR));
lpszUrl += dwLen;
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
{
WCHAR szPort[MAX_WORD_DIGITS];
sprintfW(szPort, percentD, lpUrlComponents->nPort);
*lpszUrl = ':';
lpszUrl++;
dwLen = strlenW(szPort);
memcpy(lpszUrl, szPort, dwLen * sizeof(WCHAR));
lpszUrl += dwLen;
}
/* add slash between hostname and path if necessary */
if (lpUrlComponents->lpszUrlPath && *lpUrlComponents->lpszUrlPath != '/')
{
......@@ -4024,22 +4039,14 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
}
}
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
{
WCHAR szPort[MAX_WORD_DIGITS];
sprintfW(szPort, percentD, lpUrlComponents->nPort);
*lpszUrl = ':';
lpszUrl++;
dwLen = strlenW(szPort);
memcpy(lpszUrl, szPort, dwLen * sizeof(WCHAR));
if (lpUrlComponents->lpszUrlPath)
{
dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, UrlPath);
memcpy(lpszUrl, lpUrlComponents->lpszUrlPath, dwLen * sizeof(WCHAR));
lpszUrl += dwLen;
}
dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, UrlPath);
memcpy(lpszUrl, lpUrlComponents->lpszUrlPath, dwLen * sizeof(WCHAR));
lpszUrl += dwLen;
*lpszUrl = '\0';
return TRUE;
......
......@@ -49,6 +49,7 @@
#define CREATE_URL8 "https://username:password@www.winehq.org/site/about"
#define CREATE_URL9 "about:blank"
#define CREATE_URL10 "about://host/blank"
#define CREATE_URL11 "about:"
static HANDLE hCompleteEvent;
......@@ -1129,8 +1130,22 @@ static void InternetCreateUrlA_test(void)
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);
ok(len == strlen(CREATE_URL10), "Expected len %d, got %ld\n", strlen(CREATE_URL10), len);
ok(!strcmp(szUrl, CREATE_URL10), "Expected %s, got %s\n", CREATE_URL10, szUrl);
HeapFree(GetProcessHeap(), 0, szUrl);
memset(&urlComp, 0, sizeof(urlComp));
urlComp.dwStructSize = sizeof(URL_COMPONENTS);
urlComp.nPort = 8080;
urlComp.lpszScheme = "about";
len = strlen(CREATE_URL11);
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_URL11), "Expected len %d, got %ld\n", strlen(CREATE_URL11), len);
ok(!strcmp(szUrl, CREATE_URL11), "Expected %s, got %s\n", CREATE_URL11, szUrl);
HeapFree(GetProcessHeap(), 0, szUrl);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment