Skip to content

fix(parser,rules): an overflowing class attribute is cut by the tokenizer's own reading and the page noticed, not the audit failed #1557 #1569 #1570 #1571 - #1574

Closed
nc9 wants to merge 4 commits into
mainfrom
r2/class-overflow-1557
Closed

nc9 wants to merge 4 commits into
mainfrom
r2/class-overflow-1557

Conversation

@nc9

@nc9 nc9 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • packages/parser/src/dom.ts: where to cut an overflowing class now comes from htmlparser2's Parser (the tokenizer linkedom parses with), run with linkedom's own options and attribute events overridden to report offsets. The hand-written scanner of fix(parser,rules): a class attribute that overflows the parse is cut and the page noticed, not the audit failed #1557 #1558 is gone, so there is no second reading of the markup to disagree with the parse. Only the first class of a real tag, spelt exactly class, is read (as linkedom reads it); a tag cut off by the end of the page is not cut.
  • A RangeError retries once with the cut text; any other error, nothing to cut, or a second throw ends in an empty document plus a notice. The "no root" re-parse path is contained too.
  • className splits on the five ASCII whitespace characters (parser: linkedom folds NBSP, U+2003, U+FEFF and VT in a class value to a space #1567); NBSP, U+2003, U+FEFF and VT stay inside a token.
  • The CLI's parsePageRecord carries parseNotices (parity test across all three producers); html-parse has its own solution text; docs list both checks.
  • Second commit (review fixes): an entity-led token at the cut now uses the tokenizer's own entityStart, so a class made only of entities is cut at the right place (4 new differential cases, failing before); a test pins that this package and linkedom resolve the same htmlparser2 copy.
  • New dependency: htmlparser2 ^10.1.0 in packages/parser (the version linkedom already resolves; lockfile gains one line).

Acceptance criteria

Skills: no agent skill change needed.

nc9 added 3 commits November 4, 2026 06:26
…and the page noticed, not the audit failed #1557

Signed-off-by: Nik Cubrilovic <[email protected]>
(cherry picked from commit 911dcc0)
…ing, notice it on every path, split class on HTML whitespace #1557 #1569 #1570 #1571 #1567

Cut offsets come from htmlparser2's Parser (linkedom's own tokenizer and options), not a hand-written scanner: comments, bogus comments, CDATA, raw-text elements, entity whitespace, duplicate and upper-case class no longer steer the cut. The CLI's parsePageRecord carries the notice, html-parse has its own solution text, retry is RangeError-only and any throw ends in an empty document. className splits on ASCII whitespace.

Signed-off-by: Nik Cubrilovic <[email protected]>
…okenizer's entity start; state the #1567 residual #1557 #1567

Signed-off-by: Nik Cubrilovic <[email protected]>
…n, not mock.module (it leaked into later test files) #1557 #1571

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Shipped in v0.0.161. The commits were cherry-picked onto the release branch and rebase-merged: b7ea286 b576fa9 50b3a74 84b1871.

Closing this PR since the change is on main.

nik

@nc9 nc9 closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant