fix: prevent ReDoS in extractMeta regex by anchoring to splice boundary

Co-Authored-By: deepseek-v4-pro <deepseek-ai@claude-code-best.win>
This commit is contained in:
claude-code-best
2026-06-14 17:57:52 +08:00
parent dfa70f6e7d
commit d2d4cb67d2

View File

@@ -86,10 +86,9 @@ export function extractMeta(source: string): {
const meta = validateMeta(metaObj)
// Strip the meta statement (including trailing semicolon and extra blank lines)
const body = (source.slice(0, match.index) + source.slice(i)).replace(
/[ \t]*;[ \t]*\n/,
'\n',
)
const body =
source.slice(0, match.index) +
source.slice(i).replace(/^[ \t]*;[ \t]*\n/, '\n')
return { meta, body }
}