Repository navigation
Conversation
…and in large Next.js flight scripts are read again #1435 Signed-off-by: Nik Cubrilovic <[email protected]>
5 tasks done
…tion, flight cut not dropped, runtime fixture hex, flight caveat in docs #1435 Signed-off-by: Nik Cubrilovic <[email protected]>
…ntifier pattern backtracked); ReDoS tests for every pageMarkup shape #1435 Signed-off-by: Nik Cubrilovic <[email protected]>
This was referenced Oct 31, 2026
Merged
Contributor
Author
|
Landed in v0.0.150 as nik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1435
v0.0.149's
pageMarkup(#1431) kept an inline<script>body only when it was at most 16 KB and itstypewas a JavaScript MIME type. That lost real loader installs: Clarity on 29 corpus sites (16 Next.js App Router layouts whosenext/scriptsnippet sits in aself.__next_f.pushscript over 16 KB, 3litespeed/javascript, 1 Cloudflare Rocket Loader<hash>-text/javascript) and the same loaders of other vendors.Change
__NEXT_DATA__,__nuxt_data__), import maps, speculation rules, templates,text/html|css|markdown|csv|xml. Any other type is read:litespeed/javascript, Rocket Loader's<hash>-text/javascript, Partytown, a consent tool'stext/plain. A deny-list of data types instead of an allow-list of JS types, so the next cache wrapper is not a regression.self.__next_f/self.__next_sat its start) is read up to 2 MB. 8 MB of inline text is read per page in total.<a>,<meta>(a CSP meta included) are not read.Tests
script-url-wrappers-1435.test.ts(9): LiteSpeed, Rocket Loader, other executable types, a 16 KB+ flight script with the layout snippet (with and without script bodies attached), a non-flight 16 KB+ script is not read; negatives: CSP meta, prose, link, JSON-LD,__NEXT_DATA__,__nuxt_data__, import map, template, and a data type with a wrapper-like prefix; cost and per-page cap. The #1430 tests stay green.Checks
main: no differences, none added.x-tmpl|mustache|handlebars|jquery-tmpl|jsrender|underscore|ejs, shader, octet-stream); a leading comment no longer hides a flight script; a flight script over 2 MB is cut at 2 MB, not dropped; the secret-scan fixture hex is built at run time.sameAs, meta description, CSP meta, link, prose) matches inside it, as it did before fix(tech-detect): script-url signatures always read the page markup #1430 #1431. Docs and CHANGELOG say so; narrowing the flight read is filed as tech-detect: a Next.js flight script re-opens the prose, link and metadata false-positive classes for script-url signatures #1437.Docs:
cloud/technologies.mdx. Skill change: none.nik
ReDoS audit (automated flag, #1436)
Every regex in
pageMarkupand its helpers, driven with adversarial 1 MB and 5 MB inputs (script-markup-redos-1435.test.ts, 17 shapes, each under 3 s): repeated<scriptopeners with no>, unbalanced and alternating quotes,<a x='>repeated, a 5 MBtypevalue, an unterminatedtype, hex and dashes before-text/javascript, a run of spaces before=, manytypewords, manyself.__next_f.push(openers, many small flight scripts, comment prefixes, scripts that never close, runs of<and>.^\s*(?:\/\*[\s\S]{0,200}?\*\/\s*|\/\/...)*...) had a nested quantifier: 512 characters of/* x */repeated took about a second per script, so a page of many such scripts hung the scan (a 5 MB page did not finish in 120 s). It is replaced by a linear scan (startsAsFlightScript, no regular expression). The shape is a test and fails on the old pattern.typeattribute patterns (anchored or single-pass, the tag text bounded to 64 KB),</scriptsearch (one forward scan), the quote-aware tag end (bounded to 64 KB then the first>).<img alt="; the same input takes 5.4 s on v0.0.147, so it is not from fix(tech-detect): script-url signatures always read the page markup #1430 #1431 or fix(tech-detect): inline loaders under litespeed/rocket-loader types and in large Next.js flight scripts are read again #1435 #1436.