wininet: More InternetCreateUrlW fixes.
- Don't add double slashes for opaque URLs. - The default port number for all other schemes is 0.
This commit is contained in:
parent
e58a448c4a
commit
8eab78c235
|
@ -3700,9 +3700,23 @@ static BOOL url_uses_default_port(INTERNET_SCHEME nScheme, INTERNET_PORT nPort)
|
||||||
(nPort == INTERNET_DEFAULT_GOPHER_PORT))
|
(nPort == INTERNET_DEFAULT_GOPHER_PORT))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
if (nPort == INTERNET_INVALID_PORT_NUMBER)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* opaque urls do not fit into the standard url hierarchy and don't have
|
||||||
|
* two following slashes */
|
||||||
|
static inline BOOL scheme_is_opaque(INTERNET_SCHEME nScheme)
|
||||||
|
{
|
||||||
|
return (nScheme != INTERNET_SCHEME_FTP) &&
|
||||||
|
(nScheme != INTERNET_SCHEME_GOPHER) &&
|
||||||
|
(nScheme != INTERNET_SCHEME_HTTP) &&
|
||||||
|
(nScheme != INTERNET_SCHEME_HTTPS) &&
|
||||||
|
(nScheme != INTERNET_SCHEME_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
static LPCWSTR INTERNET_GetSchemeString(INTERNET_SCHEME scheme)
|
static LPCWSTR INTERNET_GetSchemeString(INTERNET_SCHEME scheme)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
@ -3742,7 +3756,9 @@ static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents,
|
||||||
*lpdwUrlLength += strlenW(scheme);
|
*lpdwUrlLength += strlenW(scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
*lpdwUrlLength += strlen("://");
|
(*lpdwUrlLength)++; /* ':' */
|
||||||
|
if (!scheme_is_opaque(nScheme) || lpUrlComponents->lpszHostName)
|
||||||
|
*lpdwUrlLength += strlen("//");
|
||||||
|
|
||||||
if (lpUrlComponents->lpszUserName)
|
if (lpUrlComponents->lpszUserName)
|
||||||
{
|
{
|
||||||
|
@ -3909,7 +3925,7 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
|
||||||
DWORD dwLen;
|
DWORD dwLen;
|
||||||
INTERNET_SCHEME nScheme;
|
INTERNET_SCHEME nScheme;
|
||||||
|
|
||||||
static const WCHAR colonSlashW[] = {':','/','/'};
|
static const WCHAR slashSlashW[] = {'/','/'};
|
||||||
static const WCHAR percentD[] = {'%','d',0};
|
static const WCHAR percentD[] = {'%','d',0};
|
||||||
|
|
||||||
TRACE("(%p,%ld,%p,%p)\n", lpUrlComponents, dwFlags, lpszUrl, lpdwUrlLength);
|
TRACE("(%p,%ld,%p,%p)\n", lpUrlComponents, dwFlags, lpszUrl, lpdwUrlLength);
|
||||||
|
@ -3960,8 +3976,15 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
|
||||||
lpszUrl += dwLen;
|
lpszUrl += dwLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(lpszUrl, colonSlashW, sizeof(colonSlashW));
|
/* all schemes are followed by at least a colon */
|
||||||
lpszUrl += sizeof(colonSlashW)/sizeof(colonSlashW[0]);
|
*lpszUrl = ':';
|
||||||
|
lpszUrl++;
|
||||||
|
|
||||||
|
if (!scheme_is_opaque(nScheme) || lpUrlComponents->lpszHostName)
|
||||||
|
{
|
||||||
|
memcpy(lpszUrl, slashSlashW, sizeof(slashSlashW));
|
||||||
|
lpszUrl += sizeof(slashSlashW)/sizeof(slashSlashW[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (lpUrlComponents->lpszUserName)
|
if (lpUrlComponents->lpszUserName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1111,11 +1111,9 @@ static void InternetCreateUrlA_test(void)
|
||||||
len = strlen(CREATE_URL9);
|
len = strlen(CREATE_URL9);
|
||||||
szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
|
szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
|
||||||
ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
|
ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
|
||||||
todo_wine {
|
|
||||||
ok(ret, "Expected success\n");
|
ok(ret, "Expected success\n");
|
||||||
ok(len == strlen(CREATE_URL9), "Expected len %d, got %ld\n", strlen(CREATE_URL9), len);
|
ok(len == strlen(CREATE_URL9), "Expected len %d, got %ld\n", strlen(CREATE_URL9), len);
|
||||||
ok(!strcmp(szUrl, CREATE_URL9), "Expected %s, got %s\n", CREATE_URL9, szUrl);
|
ok(!strcmp(szUrl, CREATE_URL9), "Expected %s, got %s\n", CREATE_URL9, szUrl);
|
||||||
}
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, szUrl);
|
HeapFree(GetProcessHeap(), 0, szUrl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue