From 2ca477c83111a00740ecd587c623e8bdee3a34b6 Mon Sep 17 00:00:00 2001 From: Maciej Borsz Date: Tue, 16 Mar 2010 19:58:25 +0100 Subject: [PATCH] winhttp: Fix invalid behaviour of WinHttpCrackUrl. --- dlls/winhttp/tests/url.c | 19 +++++++++++++++++++ dlls/winhttp/url.c | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dlls/winhttp/tests/url.c b/dlls/winhttp/tests/url.c index c1930bec7d0..e75335129d2 100644 --- a/dlls/winhttp/tests/url.c +++ b/dlls/winhttp/tests/url.c @@ -65,6 +65,8 @@ static const WCHAR url10[] = static const WCHAR url11[] = {'h','t','t','p','s',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d', '@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','4','4','3','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0}; +static const WCHAR url12[] = + {'h','t','t','p',':','/','/','e','x','a','m','p','l','e','.','n','e','t','/','p','a','t','h','?','v','a','r','1','=','e','x','a','m','p','l','e','@','e','x','a','m','p','l','e','.','c','o','m','&','v','a','r','2','=','x','&','v','a','r','3','=','y', 0}; @@ -565,6 +567,23 @@ static void WinHttpCrackUrl_test( void ) 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 ); + ret = WinHttpCrackUrl( url12, 0, 0, &uc); + + ok( ret, "WinHttpCrackUrl failed\n" ); + ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" ); + ok( uc.lpszScheme == url12,"unexpected scheme\n" ); + ok( uc.dwSchemeLength == 4, "unexpected scheme length\n" ); + ok( uc.lpszUserName == NULL, "unexpected username\n" ); + ok( uc.lpszPassword == NULL, "unexpected password\n" ); + ok( uc.lpszHostName == url12 + 7, "unexpected hostname\n" ); + ok( uc.dwHostNameLength == 11, "unexpected hostname length\n" ); + ok( uc.nPort == 80, "unexpected port: %u\n", uc.nPort ); + ok( uc.lpszUrlPath == url12 + 18, "unexpected path\n" ); + ok( uc.dwUrlPathLength == 5, "unexpected path length\n" ); + ok( uc.lpszExtraInfo == url12 + 23, "unexpected extra info\n" ); + ok( uc.dwExtraInfoLength == 39, "unexpected extra info length\n" ); } START_TEST(url) diff --git a/dlls/winhttp/url.c b/dlls/winhttp/url.c index 49ffc4fe1ab..09835b43c91 100644 --- a/dlls/winhttp/url.c +++ b/dlls/winhttp/url.c @@ -133,7 +133,7 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN p += 2; if (!p[0]) goto exit; - if ((q = memchrW( p, '@', len - (p - url) ))) + if ((q = memchrW( p, '@', len - (p - url) )) && !(memchrW( p, '/', q - p ))) { if ((r = memchrW( p, ':', q - p ))) {