wininet: Include trailing slash in URL cache hashes.

This commit is contained in:
Jacek Caban 2014-07-16 11:06:24 +02:00 committed by Alexandre Julliard
parent 95db4ce751
commit 2aaff6e19f
2 changed files with 41 additions and 1 deletions

View File

@ -1035,6 +1035,45 @@ static void test_GetDiskInfoA(void)
ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
}
static BOOL cache_entry_exists(const char *url)
{
static char buf[10000];
DWORD size = sizeof(buf);
BOOL ret;
ret = GetUrlCacheEntryInfoA(url, (void*)buf, &size);
ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND, "GetUrlCacheEntryInfoA returned %x (%u)\n", ret, GetLastError());
return ret;
}
static void test_trailing_slash(void)
{
char filename[MAX_PATH];
BYTE zero_byte = 0;
BOOL ret;
static const FILETIME filetime_zero;
static char url_with_slash[] = "http://testing.cache.com/";
ret = CreateUrlCacheEntryA(url_with_slash, 0, "html", filename, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntryA("Visited: http://testing.cache.com/", NULL, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
ok(cache_entry_exists("Visited: http://testing.cache.com/"), "cache entry does not exist\n");
ok(!cache_entry_exists("Visited: http://testing.cache.com"), "cache entry exists\n");
ret = DeleteUrlCacheEntryA("Visited: http://testing.cache.com/");
ok(ret, "DeleteCacheEntryA failed\n");
DeleteFileA(filename);
}
START_TEST(urlcache)
{
HMODULE hdll;
@ -1058,4 +1097,5 @@ START_TEST(urlcache)
test_urlcacheW();
test_FindCloseUrlCache();
test_GetDiskInfoA();
test_trailing_slash();
}

View File

@ -1487,7 +1487,7 @@ static DWORD urlcache_hash_key(LPCSTR lpszKey)
for (i = 0; i < sizeof(key) / sizeof(key[0]); i++)
key[i] = lookupTable[(*lpszKey + i) & 0xFF];
for (lpszKey++; *lpszKey && ((lpszKey[0] != '/') || (lpszKey[1] != 0)); lpszKey++)
for (lpszKey++; *lpszKey; lpszKey++)
{
for (i = 0; i < sizeof(key) / sizeof(key[0]); i++)
key[i] = lookupTable[*lpszKey ^ key[i]];