Robert Shearman : wininet:
Make InternetCrackUrlW set the components related to net_loc
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Mar 14 12:04:33 CST 2006
Module: wine
Branch: refs/heads/master
Commit: 366fc247fcc27a4208d6e8ec081138726462538d
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=366fc247fcc27a4208d6e8ec081138726462538d
Author: Robert Shearman <rob at codeweavers.com>
Date: Tue Mar 14 14:35:37 2006 +0000
wininet: Make InternetCrackUrlW set the components related to net_loc
to NULL when net_loc isn't present in the input URL.
---
dlls/wininet/internet.c | 22 +++++++++++++---------
dlls/wininet/tests/http.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 73c3a15..42eb61d 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1337,13 +1337,13 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
break;
}
+ lpUC->nScheme = INTERNET_SCHEME_UNKNOWN;
+ lpUC->nPort = INTERNET_INVALID_PORT_NUMBER;
+
/* Parse <params> */
lpszParam = strpbrkW(lpszap, lpszSeparators);
- if (lpszParam != NULL)
- {
- SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
- lpszParam, dwUrlLength-(lpszParam-lpszUrl));
- }
+ SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
+ lpszParam, lpszParam ? dwUrlLength-(lpszParam-lpszUrl) : 0);
if (bIsAbsolute) /* Parse <protocol>:[//<net_loc>] */
{
@@ -1425,7 +1425,6 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
{
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
lpszHost, lpszPort - lpszHost);
- lpUC->nPort = 0;
lpszcp=lpszNetLoc;
}
else
@@ -1444,7 +1443,6 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
lpszcp=lpszHost;
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
NULL, 0);
- lpUC->nPort = 0;
}
else
{
@@ -1467,7 +1465,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
lpUC->nPort = INTERNET_DEFAULT_GOPHER_PORT;
break;
default:
- lpUC->nPort = INTERNET_INVALID_PORT_NUMBER;
+ break;
}
}
}
@@ -1478,9 +1476,15 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
- lpUC->nPort = 0;
}
}
+ else
+ {
+ SetUrlComponentValueW(&lpUC->lpszScheme, &lpUC->dwSchemeLength, NULL, 0);
+ SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
+ SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
+ SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
+ }
/* Here lpszcp points to:
*
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 093fb74..6611572 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -683,6 +683,7 @@ static void InternetCrackUrlW_test(void)
'C','F','I','D','E','/','m','a','i','n','.','c','f','m','?','C','F','S','V','R',
'=','I','D','E','&','A','C','T','I','O','N','=','I','D','E','_','D','E','F','A',
'U','L','T', 0 };
+ static const WCHAR url2[] = { '.','.','/','R','i','t','z','.','x','m','l',0 };
URL_COMPONENTSW comp;
WCHAR scheme[20], host[20], user[20], pwd[20], urlpart[50], extra[50];
BOOL r;
@@ -762,6 +763,35 @@ static void InternetCrackUrlW_test(void)
ok( comp.dwPasswordLength == 0, "password length wrong\n");
ok( comp.dwUrlPathLength == 15, "url length wrong\n");
ok( comp.dwExtraInfoLength == 29, "extra length wrong\n");
+
+ urlpart[0]=0;
+ scheme[0]=0;
+ extra[0]=0;
+ host[0]=0;
+ user[0]=0;
+ pwd[0]=0;
+ memset(&comp, 0, sizeof(comp));
+ comp.dwStructSize = sizeof(comp);
+ comp.lpszScheme = scheme;
+ comp.dwSchemeLength = sizeof(scheme)/sizeof(scheme[0]);
+ comp.lpszHostName = host;
+ comp.dwHostNameLength = sizeof(host)/sizeof(host[0]);
+ comp.lpszUserName = user;
+ comp.dwUserNameLength = sizeof(user)/sizeof(user[0]);
+ comp.lpszPassword = pwd;
+ comp.dwPasswordLength = sizeof(pwd)/sizeof(pwd[0]);
+ comp.lpszUrlPath = urlpart;
+ comp.dwUrlPathLength = sizeof(urlpart)/sizeof(urlpart[0]);
+ comp.lpszExtraInfo = extra;
+ comp.dwExtraInfoLength = sizeof(extra)/sizeof(extra[0]);
+
+ r = InternetCrackUrlW(url2, 0, 0, &comp);
+ ok( r, "InternetCrackUrl failed, error %lx\n",GetLastError());
+ ok(!comp.dwSchemeLength,".dwSchemeLength should be 0, but is %ld\n", comp.dwSchemeLength);
+ ok(!comp.dwHostNameLength,".dwHostNameLength should be 0, but is %ld\n", comp.dwHostNameLength);
+ ok(!comp.dwUserNameLength,".dwUserNameLength should be 0, but is %ld\n", comp.dwUserNameLength);
+ ok(!comp.dwPasswordLength,".dwPasswordLength should be 0, but is %ld\n", comp.dwPasswordLength);
+ ok(!comp.dwExtraInfoLength,".dwExtraInfoLength should be 0, but is %ld\n", comp.dwExtraInfoLength);
}
static void InternetTimeFromSystemTimeA_test(void)
More information about the wine-cvs
mailing list