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 {
155155 * But we are supporting that. So this is a fallback for that.
156156 */
157157 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":' )
159159 . replace ( / ( \] | [ 0 - 9 ] ) \s + (? = " ) / u, "$1," ) ;
160160
161161 try {
Original file line number Diff line number Diff line change @@ -254,6 +254,11 @@ describe("ConfigCommentParser", () => {
254254 } ,
255255 } ) ;
256256 } ) ;
257+
258+ it ( "should not timeout for large inputs" , ( ) => {
259+ const code = `${ "A" . repeat ( 100_000 ) } ?: 1 B: 2` ;
260+ commentParser . parseJSONLikeConfig ( code ) ;
261+ } ) ;
257262 } ) ;
258263
259264 describe ( "parseDirective" , ( ) => {
You can’t perform that action at this time.
0 commit comments