Skip to content

Commit 40f4820

Browse files
committed
Fixed parsing of comma separated multiple cookies in one header field.
https://tools.ietf.org/html/rfc2965
1 parent 072b490 commit 40f4820

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

cookiejar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
return this.name + "=" + this.value;
6363
};
6464

65-
var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g;
65+
var cookie_str_splitter = /[,](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g;
6666
Cookie.prototype.parse = function parse(str, request_domain, request_path) {
6767
if (this instanceof Cookie) {
6868
var parts = str.split(";").filter(function (value) {

tests/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ assert.equal(cookie.domain, ".test.com");
2626
var test_jar = CookieJar();
2727
test_jar.setCookies(
2828
"a=1;domain=.test.com;path=/"
29-
+":b=2;domain=test.com;path=/"
30-
+":c=3;domain=test.com;path=/;expires=January 1, 1970");
29+
+",b=2;domain=test.com;path=/"
30+
+",c=3;domain=test.com;path=/;expires=January 1, 1970");
3131
var cookies=test_jar.getCookies(CookieAccessInfo("test.com","/"))
3232
assert.equal(cookies.length, 2, "Expires on setCookies fail\n" + cookies.toString());
3333
assert.equal(cookies.toValueString(), 'a=1;b=2', "Cannot get value string of multiple cookies");

0 commit comments

Comments
 (0)