winhttp: Set last error for invalid URLs passed to WinHttpCrackUrl.
This commit is contained in:
parent
d1d0e335cf
commit
c5fa3ec216
|
@ -557,6 +557,19 @@ static void WinHttpCrackUrl_test( void )
|
||||||
ok( ret, "WinHttpCrackUrl failed\n" );
|
ok( ret, "WinHttpCrackUrl failed\n" );
|
||||||
ok( uc.nPort == 443, "unexpected port: %u\n", uc.nPort );
|
ok( uc.nPort == 443, "unexpected port: %u\n", uc.nPort );
|
||||||
|
|
||||||
|
reset_url_components( &uc );
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
ret = WinHttpCrackUrl( empty, 0, 0, &uc );
|
||||||
|
error = GetLastError();
|
||||||
|
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||||
|
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u, expected ERROR_WINHTTP_UNRECOGNIZED_SCHEME\n", error );
|
||||||
|
|
||||||
|
reset_url_components( &uc );
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
ret = WinHttpCrackUrl( http, 0, 0, &uc );
|
||||||
|
error = GetLastError();
|
||||||
|
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||||
|
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u, expected ERROR_WINHTTP_UNRECOGNIZED_SCHEME\n", error );
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(url)
|
START_TEST(url)
|
||||||
|
|
|
@ -82,7 +82,7 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
|
||||||
|
|
||||||
if (flags & ICU_ESCAPE) FIXME("flag ICU_ESCAPE not supported\n");
|
if (flags & ICU_ESCAPE) FIXME("flag ICU_ESCAPE not supported\n");
|
||||||
|
|
||||||
if (!url || !url[0] || !uc || uc->dwStructSize != sizeof(URL_COMPONENTS))
|
if (!url || !uc || uc->dwStructSize != sizeof(URL_COMPONENTS))
|
||||||
{
|
{
|
||||||
set_last_error( ERROR_INVALID_PARAMETER );
|
set_last_error( ERROR_INVALID_PARAMETER );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -114,12 +114,18 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
|
||||||
}
|
}
|
||||||
HeapFree( GetProcessHeap(), 0, url_tmp );
|
HeapFree( GetProcessHeap(), 0, url_tmp );
|
||||||
}
|
}
|
||||||
if (!(p = strchrW( url, ':' ))) return FALSE;
|
if (!(p = strchrW( url, ':' )))
|
||||||
|
{
|
||||||
|
set_last_error( ERROR_WINHTTP_UNRECOGNIZED_SCHEME );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
if (p - url == 4 && !strncmpiW( url, scheme_http, 4 )) uc->nScheme = INTERNET_SCHEME_HTTP;
|
if (p - url == 4 && !strncmpiW( url, scheme_http, 4 )) uc->nScheme = INTERNET_SCHEME_HTTP;
|
||||||
else if (p - url == 5 && !strncmpiW( url, scheme_https, 5 )) uc->nScheme = INTERNET_SCHEME_HTTPS;
|
else if (p - url == 5 && !strncmpiW( url, scheme_https, 5 )) uc->nScheme = INTERNET_SCHEME_HTTPS;
|
||||||
else goto exit;
|
else
|
||||||
|
{
|
||||||
|
set_last_error( ERROR_WINHTTP_UNRECOGNIZED_SCHEME );
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
if (!(set_component( &uc->lpszScheme, &uc->dwSchemeLength, (WCHAR *)url, p - url, flags ))) goto exit;
|
if (!(set_component( &uc->lpszScheme, &uc->dwSchemeLength, (WCHAR *)url, p - url, flags ))) goto exit;
|
||||||
|
|
||||||
p++; /* skip ':' */
|
p++; /* skip ':' */
|
||||||
|
|
Loading…
Reference in New Issue