Skip to content

Commit e42fd21

Browse files
committed
fixup! fix: remediate ReDOS further
1 parent e3e7fa6 commit e42fd21

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,22 @@ it('should trim off \\r\\n', function () {
2121
});
2222

2323
it('should not be susceptible to exponential backtracking', function () {
24+
var redosString = 'a';
25+
var count = 1000;
26+
while (count) {
27+
redosString += '\r\n';
28+
count--;
29+
}
30+
redosString += 'a';
31+
var LongerRedosString = redosString;
32+
var count = 1000;
33+
while (count) {
34+
LongerRedosString += redosString;
35+
count--;
36+
}
2437
var start = Date.now();
25-
trimOffNewlines('a' + '\r\n'.repeat(1000) + 'a');
26-
trimOffNewlines(`a${'\r\n'.repeat(1000)}a`.repeat(1000));
38+
trimOffNewlines(redosString);
39+
trimOffNewlines(LongerRedosString);
2740
var end = Date.now();
2841
assert.ok(end - start < 1000, 'took too long, probably susceptible to ReDOS');
2942
});

0 commit comments

Comments
 (0)