mainmatter / ember-cookies

Cookies abstraction for Ember.js that works both in the browser as well as with Fastboot on the server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"=" in cookie value causes ember-cookies to not see the cookie

pixelmatrix opened this issue · comments

When a valid cookie is set that contains = in the value it doesn't work. We discovered this issue because our session cookies always end in =.

document.cookie shows that the cookie is in fact present, meanwhile…
cookies.exists('session') returns false
cookies.read('session') returns undefined

It looks like the issue is where it splits the cookies by "=" and asserts that the length is === 2.
https://github.com/simplabs/ember-cookies/blob/5f83b8486ee19da877cea5c164962ec33c725e5f/addon/services/cookies.js#L196

I'm not sure if there are other edge cases here, but one solution could be to use >= 2 instead. Alternatively you could manually assemble the key and value by doing something like unfilteredCookies.map(c => [c.slice(0, c.indexOf('=')), c.slice(c.indexOf('=') + 1)]).filter(...).

I see this as well