wininet: Set last error for invalid URL argument.

This commit is contained in:
Jacek Caban 2012-09-04 17:08:06 +02:00 committed by Alexandre Julliard
parent b6ed7acce1
commit c4c3ff47e7
2 changed files with 44 additions and 6 deletions

View File

@ -360,7 +360,10 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
host[0] = 0; host[0] = 0;
ret = COOKIE_crackUrlSimple(lpszUrl, host, sizeof(host)/sizeof(host[0]), path, sizeof(path)/sizeof(path[0])); ret = COOKIE_crackUrlSimple(lpszUrl, host, sizeof(host)/sizeof(host[0]), path, sizeof(path)/sizeof(path[0]));
if (!ret || !host[0]) return FALSE; if (!ret || !host[0]) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return get_cookie(host, path, lpCookieData, lpdwSize); return get_cookie(host, path, lpCookieData, lpdwSize);
} }

View File

@ -40,6 +40,8 @@ static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR); static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD); static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR); static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
static BOOL (WINAPI *pInternetGetCookieExA)(LPCSTR,LPCSTR,LPSTR,LPDWORD,DWORD,LPVOID);
static BOOL (WINAPI *pInternetGetCookieExW)(LPCWSTR,LPCWSTR,LPWSTR,LPDWORD,DWORD,LPVOID);
/* ############################### */ /* ############################### */
@ -471,6 +473,36 @@ static void test_complicated_cookie(void)
ok(strstr(buffer,"O=P")==NULL,"O=P present\n"); ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
} }
static void test_cookie_url(void)
{
WCHAR bufw[512];
char buf[512];
DWORD len;
BOOL res;
static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
len = sizeof(buf);
res = InternetGetCookieA("about:blank", NULL, buf, &len);
ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
len = sizeof(bufw)/sizeof(*bufw);
res = InternetGetCookieW(about_blankW, NULL, bufw, &len);
ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
len = sizeof(buf);
res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
len = sizeof(bufw)/sizeof(*bufw);
res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
}
static void test_null(void) static void test_null(void)
{ {
HINTERNET hi, hc; HINTERNET hi, hc;
@ -1381,11 +1413,6 @@ START_TEST(internet)
HMODULE hdll; HMODULE hdll;
hdll = GetModuleHandleA("wininet.dll"); hdll = GetModuleHandleA("wininet.dll");
if(!GetProcAddress(hdll, "InternetGetCookieExW")) {
win_skip("Too old IE (older than 6.0)\n");
return;
}
pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA"); pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW"); pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA"); pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
@ -1395,11 +1422,19 @@ START_TEST(internet)
pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117); pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW"); pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW"); pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
if(!pInternetGetCookieExW) {
win_skip("Too old IE (older than 6.0)\n");
return;
}
test_InternetCanonicalizeUrlA(); test_InternetCanonicalizeUrlA();
test_InternetQueryOptionA(); test_InternetQueryOptionA();
test_get_cookie(); test_get_cookie();
test_complicated_cookie(); test_complicated_cookie();
test_cookie_url();
test_version(); test_version();
test_null(); test_null();
test_Option_PerConnectionOption(); test_Option_PerConnectionOption();