Skip to content

Commit 0458556

Browse files
committed
Fix incorrectly disallowing equals sign in cookie value
1 parent 62b4701 commit 0458556

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

HISTORY.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
unreleased
2+
==========
3+
4+
* Fix incorrectly disallowing equals sign in cookie value
5+
16
0.9.0 / 2023-12-28
27
==================
38

index.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ var REGEXP_CACHE = Object.create(null)
4040
var REGEXP_ESCAPE_CHARS_REGEXP = /[\^$\\.*+?()[\]{}|]/g
4141

4242
/**
43-
* RegExp to match basic restricted characters for loose validation.
43+
* RegExp to match basic restricted name characters for loose validation.
4444
*/
4545

46-
var RESTRICTED_CHARS_REGEXP = /[;=]/
46+
var RESTRICTED_NAME_CHARS_REGEXP = /[;=]/
47+
48+
/**
49+
* RegExp to match basic restricted value characters for loose validation.
50+
*/
51+
52+
var RESTRICTED_VALUE_CHARS_REGEXP = /[;]/
4753

4854
/**
4955
* RegExp to match Same-Site cookie attribute value.
@@ -144,11 +150,11 @@ Cookies.prototype.set = function(name, value, opts) {
144150
};
145151

146152
function Cookie(name, value, attrs) {
147-
if (!fieldContentRegExp.test(name) || RESTRICTED_CHARS_REGEXP.test(name)) {
153+
if (!fieldContentRegExp.test(name) || RESTRICTED_NAME_CHARS_REGEXP.test(name)) {
148154
throw new TypeError('argument name is invalid');
149155
}
150156

151-
if (value && (!fieldContentRegExp.test(value) || RESTRICTED_CHARS_REGEXP.test(value))) {
157+
if (value && (!fieldContentRegExp.test(value) || RESTRICTED_VALUE_CHARS_REGEXP.test(value))) {
152158
throw new TypeError('argument value is invalid');
153159
}
154160

0 commit comments

Comments
 (0)