Repository navigation
Conversation
5 tasks done
…e's tags instead of rescanning the HTML per signature #1456 Signed-off-by: Nik Cubrilovic <[email protected]>
…he parsed tags per call, bounds tests; honest behaviour list #1456 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/tech-tag-attr-1456
branch
from
November 1, 2026 02:02
156d276 to
4e24099
Compare
Merged
Contributor
Author
|
Landed in v0.0.154 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 #1456. Coordinates with #1464 (Klaviyo): no shared lines, this PR touches the Clerk lines of
other.ts, not the Klaviyo block.Cause and change
Signatures that matched a script
src, a stylesheetlinkor adata-*flag were regexes starting at<script\s,<link\b, ... with a bounded[^>]{0,300..400}look-ahead. Bounded per pattern, but a page of unclosed openers pays it after every opener for about a hundred signatures: 5 MB of<scripttook 20 to 30 s.tag-attr(tags,attrs,pattern, optionaltokensforsrcset-style lists). The page pass that already buildspageMarkupnow also keeps the attributes ofscript,link,img,source,iframe,video,audio,embed,objectandinputtags (quote-aware, linear, comments excluded; 100,000 tags and 100 attributes per tag at most), and atag-attrdetector reads that list.COLLECTED_TAGSis shared; a detector on a tag the pass does not keep throws where it is built.scriptSrc()andresourceAttr()buildtag-attrdetectors, so every signature that used them moves;facebook-pixel's script src, Clerk's two script attribute flags, RequireJSdata-mainand the five<link href>CSS-framework patterns ingenerated.ts(hand edit: the generated file's source data is not in the repo) were converted by hand.Measured (5 MB pages, whole
detectTechnologies, loaded machine)<scriptopeners<script x="<linkopeners<imgopenersFifteen tag names x (open, quote) were run: none above 1.8 s.
Equivalence
srcorhrefis found; a tag that repeats an attribute uses the first, as browsers do. Gone: matches that were only text, which the old per-signature regex scan accepted:document.write('<script src=...>')in inline JavaScript, a tag written inside a string literal, alinkhref inside a script string, tag text inside an attribute value, and a commented-out<script src=...>.Tests
tag-attr-1456.test.ts(15): quoted, single-quoted, unquoted, late and upper-casesrc; commented-out tag,data-src, anchor and prose negatives; stylesheet link, link-is-not-anchor; Clerk and RequireJS data attributes; Meta Pixel; the unknown-tag guard; 5 MB hostile pages (script, link, img, iframe x unclosed openers and unbalanced quotes, under 6 s). All tech-detect suites pass;tsgoclean.Docs: none (internal). CHANGELOG bullet. Skill change: none. The corpus check (53) is for after release.
nik
Review round
<img>: 50 MB became 499 MB, 255 MB retained). Now only the attribute names sometag-attrdetector reads are kept (derived from the signature list in use, per call), tags with none are not kept, the walk over a tag's attributes is bounded, and the parsed tags and markup are dropped when the call returns.<img a="+ newline and<script a='+ newline openers at 5 MB, a 1 MB attribute value onimgand onscript src, and a heap check after 8 MB of 100-attribute tags (under 60 MB retained). Closes the bounds criterion of tech-detect: in-tag script, link and img patterns are quadratic on line-start openers inside a quoted attribute #1474.