-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ambiguity on setting a cookie with "" (empty string) as the path. #242
Comments
I don't think I have a strong opinion on this, though of course changing this might lead to backwards incompat. @DCtheTall @inexorabletash @ayuishii? |
Agreed - no strong feelings either way. Logically, feels like a Chromium bug but also seems harmless to support if needed for compat. Does the FF impl treat this as an error? If so that could inform compat risk. |
cc @bakulf |
@RupinMittal what does "fills in the path itself" mean? Does it take the path from the url argument? |
My understanding is that Firefox is not shipping this API yet, though they are actively working on it. We could maybe check their behavior using a nightly build but I don't think it would inform compat risk? |
Since Moz has already done some amount of compat consideration about shipping only a subset of the API that Chrome shipped, I was hoping they might have noticed any issues here as well. A bit of a stretch, though. |
Firefox: Chrome:
As opposed to:
|
In Firefox, I was able to set cookies on Nightly at https://worker-playground.glitch.me/ specifically pasting in code like the following based on https://developer.mozilla.org/en-US/docs/Web/API/CookieStore#examples: const day = 24 * 60 * 60 * 1000;
cookieStore
.set({
name: "cookie1",
value: "cookie1-value",
expires: Date.now() + day,
domain: "worker-playground.glitch.me",
path: "",
})
.then(
() => {
console.log("It worked!");
},
(reason) => {
console.error("It failed: ", reason);
},
); The code currently likes to normalize an empty path to be / and that's what I observe in our devtools storage tab afterwards: nsString path(aPath);
if (path.IsEmpty() || path[path.Length() - 1] != '/') {
path.Append('/');
} Firefox currently use a gating pref that is only defaulted to true in our nightly builds. Bug 1937477 tracks enabling it to ride the trains to release. |
I guess I don't have a strong preference, but it does seem like a bit of a footgun that the empty string gives you the path of the URL. Equivalent to not passing it (thus (I could see an argument for the current behavior if the restriction on starting with |
The spec (https://wicg.github.io/cookie-store/#set-a-cookie) says that if set is called with a path passed in, and the path does not start with a "/", then we should return a failure. This implies that passing in "" should cause a failure.
However, Chrome does not return failure here, but rather fills in the path itself and sets the cookie.
Which is correct? Returning a failure or filling in the path automatically if an empty string is passed in? Thank you!
The text was updated successfully, but these errors were encountered: