File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ export class ConfigCommentParser {
155
155
* But we are supporting that. So this is a fallback for that.
156
156
*/
157
157
const normalizedString = string
158
- . replace ( / ( [ - a - z A - Z 0 - 9 / ] + ) : / gu, '"$1":' )
158
+ . replace ( / (?< ! [ - a - z A - Z 0 - 9 / ] ) ( [ - a - z A - Z 0 - 9 / ] + ) : / gu, '"$1":' )
159
159
. replace ( / ( \] | [ 0 - 9 ] ) \s + (? = " ) / u, "$1," ) ;
160
160
161
161
try {
Original file line number Diff line number Diff line change @@ -254,6 +254,11 @@ describe("ConfigCommentParser", () => {
254
254
} ,
255
255
} ) ;
256
256
} ) ;
257
+
258
+ it ( "should not timeout for large inputs" , ( ) => {
259
+ const code = `${ "A" . repeat ( 100_000 ) } ?: 1 B: 2` ;
260
+ commentParser . parseJSONLikeConfig ( code ) ;
261
+ } ) ;
257
262
} ) ;
258
263
259
264
describe ( "parseDirective" , ( ) => {
You can’t perform that action at this time.
0 commit comments