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

URL Decoding of Raw Cookie Values #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ Cookies.prototype.get = function(name, opts) {
match = header.match(getPattern(name))
if (!match) return

value = match[1]
/*
* https://tools.ietf.org/html/rfc6265#section-4.1.1
*
* To maximize compatibility with user agents, servers that wish to
* store arbitrary data in a cookie-value SHOULD encode that data, for
* example, using Base64 [RFC4648].
*/
value = decodeURIComponent(match[1])
if (!opts || !signed) return value

remote = this.get(sigName)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cookies",
"description": "Cookies, optionally signed using Keygrip.",
"version": "0.7.3",
"version": "0.7.4",
"author": "Jed Schmidt <[email protected]> (http://jed.is)",
"contributors": [
"Douglas Christopher Wilson <[email protected]>"
Expand Down
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ describe('new Cookies(req, res, [options])', function () {
res.end(String(cookies.get('foo')))
}))
.get('/')
.set('Cookie', 'foo=bar')
.expect(200, 'bar', done)
.set('Cookie', 'foo=bar%3D')
.expect(200, 'bar=', done)
})

it('should work for cookie name with special characters', function (done) {
Expand Down