Skip to content
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

Cookie keys are not encoded in a way that is compliant with RFC6265 #18

Closed
ScottHamper opened this issue Nov 21, 2013 · 3 comments
Closed
Assignees
Labels

Comments

@ScottHamper
Copy link
Owner

See Issue 17 for background.

encodeURIComponent is currently being used to encode cookie keys. However, this function escapes some characters that are allowed to be in a cookie key, and does not escape some characters that are not allowed to be in a cookie key, as defined by RFC6265.

@gziolo
Copy link

gziolo commented Apr 23, 2014

I think I have similar issue when trying to get key from cookie:

URIError: malformed URI sequence
Cookies._getKeyValuePairFromCookieString()main_c...s_17.js (wiersz 111)
Cookies._getCookieObjectFromString()main_c...s_17.js (wiersz 92)
Cookies._renewCache()main_c...s_17.js (wiersz 116)
Cookies.get()main_c...s_17.js (wiersz 27)

I will try to find cookie string that causes issue.

@ScottHamper
Copy link
Owner Author

Grzegorz,
Your error is likely due to a cookie value being encoded in something other than UTF-8.

See Issue #22

@gziolo
Copy link

gziolo commented Apr 24, 2014

This time issue was caused by %uFFFD sequence which is the Unicode Replacement Character. This indicates that a given character value cannot be correctly encoded in Unicode.

I solved issue by updating Cookies._getKeyValuePairFromCookieString

with following bits of code:
value: decodeURIComponent(cookieString.substr(separatorIndex + 1).replace(/%uFFFD/gi, ''))

ScottHamper added a commit that referenced this issue Apr 27, 2014
Cookies.js was unnecessarily encoding the characters `#$%&+^\`|`, and
was not encoding `()`.

I also updated the copyright year in source files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants