Js-cookie: Cookie name with slash

Created on 17 Jan 2020  ·  3Comments  ·  Source: js-cookie/js-cookie

Describe the bug
Cookie name with slash / character is escaped to %2F
Eg. user/123=foo becomes user%2F123=foo

I believe the forward slash character is allowed in the cookie key.

It's unclear why you're passing key here as the converter expects a single parameter:
value = converter.write(value, key)

And on the next line:
https://github.com/js-cookie/js-cookie/blob/b1d83a073525e00f87d8b4effa4804b8cb741f12/src/api.mjs#L21

Perhaps it would be better to have:
key = converter.write(key)

Expected behavior
Cookie name preserves the original forward slash character.

bug

Most helpful comment

I've bumped the v3 beta containing the new implementation.

https://github.com/js-cookie/js-cookie/releases/tag/v3.0.0-beta.4

All 3 comments

RFC 6265 defines the cookie name as token, which in turn is defined in RFC 2616 as follows:

       token          = 1*<any CHAR except CTLs or separators>
       separators     = "(" | ")" | "<" | ">" | "@"
                      | "," | ";" | ":" | "\" | <">
                      | "/" | "[" | "]" | "?" | "="
                      | "{" | "}" | SP | HT

So a / needs to be encoded.

Reopening as valid, see discussion in #595.

I've bumped the v3 beta containing the new implementation.

https://github.com/js-cookie/js-cookie/releases/tag/v3.0.0-beta.4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luis-pato picture luis-pato  ·  6Comments

yaconnn picture yaconnn  ·  6Comments

Neve12ende12 picture Neve12ende12  ·  3Comments

oninross picture oninross  ·  9Comments

BonBonSlick picture BonBonSlick  ·  9Comments