Skip to content

Commit 544d394

Browse files
committed
Fix issue when parsing invalid cookies
1 parent 207de77 commit 544d394

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

cookiejar.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,16 @@
6767
if (this instanceof Cookie) {
6868
var parts = str.split(";").filter(function (value) {
6969
return !!value;
70-
}),
71-
pair = parts[0].match(/([^=]+)=([\s\S]*)/),
72-
key = pair[1],
73-
value = pair[2],
74-
i;
70+
});
71+
var i;
72+
73+
var pair = parts[0].match(/([^=]+)=([\s\S]*)/);
74+
if (!pair) return;
75+
76+
var key = pair[1];
77+
var value = pair[2];
78+
if (!key || !value) return;
79+
7580
this.name = key;
7681
this.value = value;
7782

0 commit comments

Comments
 (0)