wininet: Make InternetCrackUrlW set the components related to net_loc

to NULL when net_loc isn't present in the input URL.
This commit is contained in:
Robert Shearman 2006-03-14 14:35:37 +00:00 committed by Alexandre Julliard
parent 153aac0194
commit 366fc247fc
2 changed files with 43 additions and 9 deletions

View File

@ -1337,13 +1337,13 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
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 lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
{
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
lpszHost, lpszPort - lpszHost);
lpUC->nPort = 0;
lpszcp=lpszNetLoc;
}
else
@ -1444,7 +1443,6 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
lpszcp=lpszHost;
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
NULL, 0);
lpUC->nPort = 0;
}
else
{
@ -1467,7 +1465,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
lpUC->nPort = INTERNET_DEFAULT_GOPHER_PORT;
break;
default:
lpUC->nPort = INTERNET_INVALID_PORT_NUMBER;
break;
}
}
}
@ -1478,9 +1476,15 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWOR
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:
*

View File

@ -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)