Module: wine Branch: master Commit: 465f85e89dfd6d796317ddadf5f5ab8d74d69ac3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=465f85e89dfd6d796317ddadf5...
Author: Hans Leidekker hans@codeweavers.com Date: Thu May 22 11:36:22 2014 +0200
winhttp: Ignore URL components if the buffer length is zero.
---
dlls/winhttp/tests/url.c | 33 +++++++++++++++++++++++++++++++++ dlls/winhttp/url.c | 1 + 2 files changed, 34 insertions(+)
diff --git a/dlls/winhttp/tests/url.c b/dlls/winhttp/tests/url.c index ad06fc4..f53947c 100644 --- a/dlls/winhttp/tests/url.c +++ b/dlls/winhttp/tests/url.c @@ -71,6 +71,7 @@ static const WCHAR url13[] = {'h','t','t','p','s',':','/','/','t','o','o','l','s','.','g','o','o','g','l','e','.','c','o','m','/','s','e','r','v','i','c','e','/','u','p','d','a','t','e','2','?','w','=','3',':','B','x','D','H','o','W','y','8','e','z','M',0}; static const WCHAR url14[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o',' ','g','/','p','a','t','h',' ','w','i','t','h',' ','s','p','a','c','e','s',0}; +static const WCHAR url15[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','t','e','s','t',0};
static const WCHAR url_k1[] = {'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d', @@ -625,6 +626,38 @@ static void WinHttpCrackUrl_test( void ) ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() ); ok( !lstrcmpW( uc.lpszHostName, hostnameW ), "unexpected host name\n" ); ok( !lstrcmpW( uc.lpszUrlPath, pathW ), "unexpected path\n" ); + + uc.dwStructSize = sizeof(uc); + uc.lpszScheme = NULL; + uc.dwSchemeLength = 0; + uc.nScheme = 0; + uc.lpszHostName = NULL; + uc.dwHostNameLength = ~0u; + uc.nPort = 0; + uc.lpszUserName = NULL; + uc.dwUserNameLength = ~0u; + uc.lpszPassword = NULL; + uc.dwPasswordLength = ~0u; + uc.lpszUrlPath = NULL; + uc.dwUrlPathLength = ~0u; + uc.lpszExtraInfo = NULL; + uc.dwExtraInfoLength = ~0u; + ret = WinHttpCrackUrl( url15, 0, 0, &uc ); + ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() ); + ok( !uc.lpszScheme, "unexpected scheme %s\n", wine_dbgstr_w(uc.lpszScheme) ); + ok( !uc.dwSchemeLength, "unexpected length %u\n", uc.dwSchemeLength ); + ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme %u\n", uc.nScheme ); + ok( !lstrcmpW( uc.lpszHostName, url15 + 7 ), "unexpected hostname %s\n", wine_dbgstr_w(uc.lpszHostName) ); + ok( uc.dwHostNameLength == 14, "unexpected length %u\n", uc.dwHostNameLength ); + ok( uc.nPort == 80, "unexpected port %u\n", uc.nPort ); + ok( !uc.lpszUserName, "unexpected username\n" ); + ok( !uc.dwUserNameLength, "unexpected length %u\n", uc.dwUserNameLength ); + ok( !uc.lpszPassword, "unexpected password\n" ); + ok( !uc.dwPasswordLength, "unexpected length %u\n", uc.dwPasswordLength ); + ok( !lstrcmpW( uc.lpszUrlPath, url15 + 21 ), "unexpected path %s\n", wine_dbgstr_w(uc.lpszUrlPath) ); + ok( uc.dwUrlPathLength == 5, "unexpected length %u\n", uc.dwUrlPathLength ); + ok( !uc.lpszExtraInfo[0], "unexpected extra info %s\n", wine_dbgstr_w(uc.lpszExtraInfo) ); + ok( uc.dwExtraInfoLength == 0, "unexpected length %u\n", uc.dwExtraInfoLength ); }
START_TEST(url) diff --git a/dlls/winhttp/url.c b/dlls/winhttp/url.c index d8b423c..9ad6ee5 100644 --- a/dlls/winhttp/url.c +++ b/dlls/winhttp/url.c @@ -36,6 +36,7 @@ static const WCHAR scheme_https[] = {'h','t','t','p','s',0};
static BOOL set_component( WCHAR **str, DWORD *str_len, WCHAR *value, DWORD len, DWORD flags ) { + if (!*str_len) return TRUE; if (!*str) { if (len && *str_len && (flags & (ICU_DECODE|ICU_ESCAPE)))