diff --git a/test.js b/test.js index a17a555..0c917f2 100644 --- a/test.js +++ b/test.js @@ -21,9 +21,22 @@ it('should trim off \\r\\n', function () { }); it('should not be susceptible to exponential backtracking', function () { + var redosString = 'a'; + var count = 1000; + while (count) { + redosString += '\r\n'; + count--; + } + redosString += 'a'; + var LongerRedosString = redosString; + var count = 1000; + while (count) { + LongerRedosString += redosString; + count--; + } var start = Date.now(); - trimOffNewlines('a' + '\r\n'.repeat(1000) + 'a'); - trimOffNewlines(`a${'\r\n'.repeat(1000)}a`.repeat(1000)); + trimOffNewlines(redosString); + trimOffNewlines(LongerRedosString); var end = Date.now(); assert.ok(end - start < 1000, 'took too long, probably susceptible to ReDOS'); });