Skip to content

2026.11.9

@ruifigueira ruifigueira tagged this 13 Nov 12:13
`<!--[\s\S]*?-->` can end at any later `-->`, so `<!----><!---->...` with no
doctype after it backtracks exponentially. Every navigation scans its HTML
with this pattern, so about 40 empty comments stalled the page isolate.

Stop each comment at its first `-->`. As a side effect, text between two
`-->` no longer counts as part of a comment, so
`<!-- a --> b --><!doctype html>` no longer reports a source doctype. The
scan still does not handle malformed comment ends such as `<!-->` or `--!>`.

The patterns move to source-doctype.ts so a unit test can run them. Its
timing check fails in about a second against the old pattern instead of
hanging the run. CodeQL js/redos and js/polynomial-redos (alerts 2, 5, 6).

beep-boop-🤖

Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
Assets 2
Loading