Fix invalid behaviour of WinHttpCrackUrl. (try 2)

Maciej Borsz maciejborsz at gmail.com
Tue Mar 16 14:02:33 CDT 2010


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20100316/3b88ae9b/attachment-0001.htm>
-------------- next part --------------
From 9c789937e8c58f5d4e175e6c35352f7a452ec2d2 Mon Sep 17 00:00:00 2001
From: Maciej Borsz <maciejborsz at gmail.com>
Date: Tue, 16 Mar 2010 19:58:25 +0100
Subject: Fix invalid behaviour of WinHttpCrackUrl. (try 2)
 Fix invalid behaviour of WinHttpCrackUrl when in url is '@'.

Added one test.
---
 dlls/winhttp/tests/url.c |   19 +++++++++++++++++++
 dlls/winhttp/url.c       |    2 +-
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/dlls/winhttp/tests/url.c b/dlls/winhttp/tests/url.c
index c1930be..e753351 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 49ffc4f..09835b4 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 )))
         {
-- 
1.6.3.3


More information about the wine-patches mailing list