Module: wine Branch: master Commit: 2aaff6e19f9ef97a241d7ca36497d47d52b4c523 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2aaff6e19f9ef97a241d7ca364...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Jul 16 11:06:24 2014 +0200
wininet: Include trailing slash in URL cache hashes.
---
dlls/wininet/tests/urlcache.c | 40 ++++++++++++++++++++++++++++++++++++++++ dlls/wininet/urlcache.c | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/dlls/wininet/tests/urlcache.c b/dlls/wininet/tests/urlcache.c index 35ef77d..f735d73 100644 --- a/dlls/wininet/tests/urlcache.c +++ b/dlls/wininet/tests/urlcache.c @@ -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(); } diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c index f0a731b..3487aa8 100644 --- a/dlls/wininet/urlcache.c +++ b/dlls/wininet/urlcache.c @@ -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]];