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 @@ -144,7 +144,7 @@ function expand (str, isTop) {
144144 const isOptions = m . body . indexOf ( ',' ) >= 0
145145 if ( ! isSequence && ! isOptions ) {
146146 // {a},b }
147- if ( m . post . match ( / , .* \} / ) ) {
147+ if ( m . post . match ( / , (? ! , ) .* \} / ) ) {
148148 str = m . pre + '{' + m . body + escClose + m . post
149149 return expand ( str )
150150 }
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