Commit 2fccd2cb authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Fix default port corner cases in WinHttpCrackUrl().

parent eda3732a
...@@ -61,6 +61,7 @@ static const WCHAR url18[] = L"http://%0D%1F%20%0A%7F%0D%0A"; ...@@ -61,6 +61,7 @@ static const WCHAR url18[] = L"http://%0D%1F%20%0A%7F%0D%0A";
static const WCHAR url19[] = L"http://?text=\xfb00"; static const WCHAR url19[] = L"http://?text=\xfb00";
static const WCHAR url20[] = L"http:///text=\xfb00"; static const WCHAR url20[] = L"http:///text=\xfb00";
static const WCHAR url21[] = L"https://nba2k19-ws.2ksports.com:19133/nba/v4/Accounts/get_account?x=3789526775265663876"; static const WCHAR url21[] = L"https://nba2k19-ws.2ksports.com:19133/nba/v4/Accounts/get_account?x=3789526775265663876";
static const WCHAR url22[] = L"http://winehq.org:/";
static const WCHAR url_k1[] = L"http://username:password@www.winehq.org/site/about"; static const WCHAR url_k1[] = L"http://username:password@www.winehq.org/site/about";
static const WCHAR url_k2[] = L"http://www.winehq.org"; static const WCHAR url_k2[] = L"http://www.winehq.org";
...@@ -807,7 +808,13 @@ static void WinHttpCrackUrl_test( void ) ...@@ -807,7 +808,13 @@ static void WinHttpCrackUrl_test( void )
uc.nPort = 1; uc.nPort = 1;
ret = WinHttpCrackUrl( url17, 0, 0, &uc ); ret = WinHttpCrackUrl( url17, 0, 0, &uc );
ok( ret, "got %lu\n", GetLastError() ); ok( ret, "got %lu\n", GetLastError() );
todo_wine ok( uc.nPort == 80, "got %u\n", uc.nPort ); ok( uc.nPort == 80, "got %u\n", uc.nPort );
reset_url_components( &uc );
uc.nPort = 1;
ret = WinHttpCrackUrl( url22, 0, 0, &uc );
ok( ret, "got %lu\n", GetLastError() );
ok( uc.nPort == 80, "got %u\n", uc.nPort );
memset( &uc, 0, sizeof(uc) ); memset( &uc, 0, sizeof(uc) );
uc.dwStructSize = sizeof(uc); uc.dwStructSize = sizeof(uc);
......
...@@ -280,13 +280,18 @@ BOOL WINAPI WinHttpCrackUrl( const WCHAR *url, DWORD len, DWORD flags, URL_COMPO ...@@ -280,13 +280,18 @@ BOOL WINAPI WinHttpCrackUrl( const WCHAR *url, DWORD len, DWORD flags, URL_COMPO
{ {
if ((err = set_component( &hostname, p, r - p, flags, &overflow ))) goto exit; if ((err = set_component( &hostname, p, r - p, flags, &overflow ))) goto exit;
r++; r++;
if ((err = parse_port( r, q - r, &uc->nPort ))) goto exit; if (!(q - r))
{
if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT;
else if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
}
else if ((err = parse_port( r, q - r, &uc->nPort ))) goto exit;
} }
else else
{ {
if ((err = set_component( &hostname, p, q - p, flags, &overflow ))) goto exit; if ((err = set_component( &hostname, p, q - p, flags, &overflow ))) goto exit;
if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT; if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT;
if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT; else if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
} }
if ((r = wmemchr( q, '?', len - (q - url) ))) if ((r = wmemchr( q, '?', len - (q - url) )))
...@@ -310,13 +315,18 @@ BOOL WINAPI WinHttpCrackUrl( const WCHAR *url, DWORD len, DWORD flags, URL_COMPO ...@@ -310,13 +315,18 @@ BOOL WINAPI WinHttpCrackUrl( const WCHAR *url, DWORD len, DWORD flags, URL_COMPO
{ {
if ((err = set_component( &hostname, p, r - p, flags, &overflow ))) goto exit; if ((err = set_component( &hostname, p, r - p, flags, &overflow ))) goto exit;
r++; r++;
if ((err = parse_port( r, len - (r - url), &uc->nPort ))) goto exit; if (!*r)
{
if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT;
else if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
}
else if ((err = parse_port( r, len - (r - url), &uc->nPort ))) goto exit;
} }
else else
{ {
if ((err = set_component( &hostname, p, len - (p - url), flags, &overflow ))) goto exit; if ((err = set_component( &hostname, p, len - (p - url), flags, &overflow ))) goto exit;
if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT; if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT;
if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT; else if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
} }
if ((err = set_component( &path, (WCHAR *)url + len, 0, flags, &overflow ))) goto exit; if ((err = set_component( &path, (WCHAR *)url + len, 0, flags, &overflow ))) goto exit;
if ((err = set_component( &extra, (WCHAR *)url + len, 0, flags, &overflow ))) goto exit; if ((err = set_component( &extra, (WCHAR *)url + len, 0, flags, &overflow ))) goto exit;
......
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