HTML Minifier Next: Regular expressions in `minify()` cause O(n²) backtracking on ignored and custom-fragment content
html-minifier-next finds the last HTML tag inside htmlmin:ignore blocks with the expression /[\s\S]<(/?[a-zA-Z][\w:-])/. A large ignore block without a matching tag makes the greedy prefix rescan the content, so the public minify() API takes about 89 seconds for 256 KB. A second expression with the same flaw, /^(\s*)[\s\S]?(\s)$/, splits whitespace off matches of ignoreCustomFragments. A long whitespace run inside such a fragment triggers it with default options, since the default …