Skip to content

Commit 4e2fb0b

Browse files
committed
Document the 256 spaces limit
1 parent f1ed420 commit 4e2fb0b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ else
134134
cookies = [Cookie.parse(res.headers['set-cookie'])];
135135
```
136136

137+
_Potentially non-standard behavior:_ currently, tough-cookie will limit the number of spaces before the `=` to 256 characters.
138+
See [Issue 92](https://github.com/salesforce/tough-cookie/issues/92)
139+
137140
### Properties
138141

139142
Cookie object properties:

lib/cookie.js

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ var COOKIE_OCTETS = new RegExp('^'+COOKIE_OCTET.source+'+$');
5353

5454
var CONTROL_CHARS = /[\x00-\x1F]/;
5555

56+
// For COOKIE_PAIR and LOOSE_COOKIE_PAIR below, the number of spaces has been
57+
// restricted to 256 to side-step a ReDoS issue reported here:
58+
// https://github.com/salesforce/tough-cookie/issues/92
59+
5660
// Double quotes are part of the value (see: S4.1.1).
5761
// '\r', '\n' and '\0' should be treated as a terminator in the "relaxed" mode
5862
// (see: https://github.com/ChromiumWebApps/chromium/blob/b3d3b4da8bb94c1b2e061600df106d590fda3620/net/cookies/parsed_cookie.cc#L60)

0 commit comments

Comments
 (0)