fix: replace remaining ReDoS-vulnerable regex in JS minify

Change `\/\/.*$/gm` to `\/\/[^\n]*/g` to avoid backtracking with
`.*` and `$` anchor in multiline mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lidong-sal 2026-06-04 16:49:01 +08:00
parent 70d0b20ac1
commit e2e7d39cf1

View file

@ -41,7 +41,7 @@ function minifyCss(input: string): string {
function minifyJs(input: string): string {
return input
.replace(/\/\*[\s\S]*?\*\//g, '')
.replace(/\/\/.*$/gm, '')
.replace(/\/\/[^\n]*/g, '')
.replace(/\s+/g, ' ')
.replace(/ ?([{}();,=:+\-*/<>!&|?]) ?/g, '$1')
.trim();