File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,22 @@ it('should trim off \\r\\n', function () {
2121} ) ;
2222
2323it ( '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} ) ;
You can’t perform that action at this time.
0 commit comments