File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ function expand(str, isTop) {
109
109
var isOptions = m . body . indexOf ( ',' ) >= 0 ;
110
110
if ( ! isSequence && ! isOptions ) {
111
111
// {a},b }
112
- if ( m . post . match ( / , .* \} / ) ) {
112
+ if ( m . post . match ( / , (? ! , ) .* \} / ) ) {
113
113
str = m . pre + '{' + m . body + escClose + m . post ;
114
114
return expand ( str ) ;
115
115
}
Original file line number Diff line number Diff line change
1
+ import test from 'node:test'
2
+ import assert from 'assert'
3
+ import expand from '../index.js'
4
+
5
+ test ( 'redos' , function ( ) {
6
+ let str = "{a}" + "," . repeat ( 100000 ) + "\u0000" ;
7
+ let startTime = performance . now ( ) ;
8
+ expand ( str )
9
+ let endTime = performance . now ( ) ;
10
+ let timeTaken = endTime - startTime ;
11
+ assert . ok ( timeTaken < 1000 , `Expected time (${ timeTaken } ms) to be less than 1000ms` ) ;
12
+ } )
13
+
14
+
15
+
You can’t perform that action at this time.
0 commit comments