Skip to content
Permalink
Browse files
Fix parsing of negative age values in CORS prefetch responses
https://bugs.webkit.org/show_bug.cgi?id=244959

Reviewed by Darin Adler.

This aligns our behavior with Blink and Gecko.

* LayoutTests/imported/w3c/web-platform-tests/cors/preflight-cache-expected.txt:
* Source/WebCore/loader/CrossOriginPreflightResultCache.cpp:
(WebCore::parseAccessControlMaxAge):

Canonical link: https://commits.webkit.org/254410@main
  • Loading branch information
cdumez committed Sep 12, 2022
1 parent 572f103 commit 46bb54071fc38dbc58e9d96598c04fdd898f9484
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
@@ -5,6 +5,6 @@ PASS Test preflight
PASS preflight for x-print should be cached
PASS age = blank, should be cached
PASS age = 0, should not be cached
FAIL age = -1, should not be cached assert_equals: did preflight expected "1" but got "0"
PASS age = -1, should not be cached
PASS preflight first request, second from cache, wait, third should preflight again

@@ -48,7 +48,7 @@ CrossOriginPreflightResultCache::CrossOriginPreflightResultCache()
static bool parseAccessControlMaxAge(const String& string, Seconds& expiryDelta)
{
// FIXME: This should probably reject strings that have a leading "+".
auto parsedInteger = parseInteger<uint64_t>(string);
auto parsedInteger = parseInteger<int64_t>(string);
expiryDelta = Seconds(static_cast<double>(parsedInteger.value_or(0)));
return parsedInteger.has_value();
}

0 comments on commit 46bb540

Please sign in to comment.