Skip to content

Commit 9a3b589

Browse files
vovikhangcdvichernev
authored andcommitted
[bugfix] Fix redos in preprocessRFC2822 regex (#6015)
* fix ReDoS in preprocessRFC2822 regex Fixes: [#2936](#6012) Disallow nested rfc2822 comments to prevent quadratic regex execution time (i.e each open bracket is considered at most twice).
1 parent 6374fd8 commit 9a3b589

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/create/from-string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function untruncateYear(yearStr) {
151151
function preprocessRFC2822(s) {
152152
// Remove comments and folding whitespace and replace multiple-spaces with a single space
153153
return s
154-
.replace(/\([^)]*\)|[\n\t]/g, ' ')
154+
.replace(/\([^()]*\)|[\n\t]/g, ' ')
155155
.replace(/(\s\s+)/g, ' ')
156156
.replace(/^\s\s*/, '')
157157
.replace(/\s\s*$/, '');

0 commit comments

Comments
 (0)