Bug 247037 - Safari strips whitespace around comma when setting with document.cookie
Summary: Safari strips whitespace around comma when setting with document.cookie
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-10-25 17:44 PDT by April King
Modified: 2022-11-03 12:44 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description April King 2022-10-25 17:44:49 PDT
Extremely bizarre bug and I'm hard pressed to think of what would cause it but running this code:

> document.cookie="foo=hello , world"
< "foo=hello , world"
> document.cookie
< "foo=hello,world"

Shows that setting a cookie to "hello , world" causes it to be saved as "hello,world".

Note that using characters besides commas seem to not have this issue:

> document.cookie="foo=hello $ world"
< "foo=hello $ world"
> document.cookie
< "foo=hello $ world"
Comment 1 Alexey Proskuryakov 2022-10-26 12:05:56 PDT
One theory is that the cookie value is parsed by a function that treats commas as in HTTP, separating multiple values.

In NetworkStorageSessionCocoa.mm:

    NSHTTPCookie *initialCookie = [NSHTTPCookie _cookieForSetCookieString:cookieString forURL:cookieURL partition:nil];
Comment 2 Radar WebKit Bug Importer 2022-11-01 17:45:19 PDT
<rdar://problem/101834060>