Repository navigation
fix(rules): read url(), blocks and escapes like a browser in content/hidden-text #679 - #685
Merged
Merged
Conversation
nc9
marked this pull request as ready for review
October 12, 2026 01:12
|
Reviewed the diff for
Positives:
|
Contributor
Author
|
Review triage (head 47eafdc, no code change):
|
…hidden-text #679 The default CSS scanner read a {, } or ; inside an unquoted url(...), a ( or [ block, or after a backslash as structure, so .a{background:url(}.b{display:none}.c{)} hid .b, which Chromium shows. parseRules and parseDeclarations now skip escapes, read an unquoted url( to its ) as one token (only where a url token can start), and track blocks so only the expected closer ends one. Still a single linear pass. Verified against 60 rows read from headless Chromium 156; a 16,859-page corpus run changes no finding. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/hidden-text-css-structure-679
branch
from
October 12, 2026 04:24
47eafdc to
848bb1e
Compare
|
Reviewed the diff for
The scanner stays a single forward pass, the url-boundary lookback is bounded, and the 60 Chromium-derived rows plus the CRLF and flood tests are solid coverage. The CHANGELOG and docs are updated. |
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.
content/hidden-textread<style>sheets and inline styles with a scanner that treated a{,}or;inside an unquotedurl(...), inside a(or[block, or after a backslash as structure. A sheet such as.a{background:url(}.b{display:none}.c{)}was read as hiding.b, which Chromium shows: the unquotedurl(is one token up to).Change
packages/rules/src/content/hidden-text.ts, inparseRules(preludes and rule bodies) andparseDeclarations(rule bodies and inlinestyle):url(runs to its)as one token, escapes included, bad-url remnants too.url("...")stays an ordinary function.url(that continues another token (after a name character,#,@, an escaped character, or the whitespace that ends a hex escape) is a function or a(block, as in a browser.(,[and{open blocks that only their own closer ends; any other closer inside is plain text.This is a port of
stepBlocks/skipUnquotedUrlfromwip/static-hidden-cascade-664-665(ee5a5d6), applied always rather than behind a strict mode, plus the token-boundary check codex found missing from that port. Everything stays one forward pass; the only lookback (url token boundaries) is bounded by six hex digits plus one backslash run that no otherurl(can share.Rule doc page and CHANGELOG updated.
Acceptance evidence
--http -m 1 --offlineagainst a local page with the issue's<style>and paragraph: origin/main reportscontent/hidden-text, this branch reports nothing. Also row 1 of the Chromium set.}and;inside an unquotedurl(...), inside(/[blocks, and after a backslash are not structure. Covered by rows for each construct, in selectors, rule bodies and inline styles.display:nonerule still produces the finding, and existing hidden-text tests pass. Rowsa plain display:none rule,an ordinary url(),a quoted url(),a data: url() with ; inside, Tailwind escaped class names,@mediawith parentheses, nested rules, allhidden. 148 hidden-text tests pass.(,[,{,uor backslashes, 100,000url(,url(+ whitespace runs, and floods aimed at the url-boundary lookback) checks each page in under a second.getComputedStyleon the payload under the row's stylesheet or inline style, with the probe asserting the browser received the exact bytes). All 60 match this branch; origin/main disagrees with Chromium on 24 of the original rows. CRLF after a hex escape cannot reach Chromium's CSS parser from HTML (the HTML parser normalizes it) but linkedom keeps it, so it has its own test.No change on ordinary stylesheets. Old vs new over a local corpus of 16,859 real pages: 312 pages parse some
<style>block or inline style differently (in a sample: JavaScript inside<style>, nested rules, an escaped quote in a string, Tailwind sheets where the old scanner lost its place), and 0 pages change their hidden-text result.Checks
bun test packages/rules/tests/hidden-text.test.ts148 pass (24 of the new rows fail on origin/main)bun test packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts packages/audit-engine/tests/scan-truncated-carry.test.ts packages/audit-engine/tests/item-locator-resolve.test.ts packages/rules/tests/item-cap-remainder.test.ts52 passpackages/rulestsgo clean; docstangly check --strictpassed#url(, escaped punctuation, CRLF after a hex escape), each fixed with a Chromium row or test; final pass "no findings"Not in this PR
A comment before a selector (
/* Section */ .b{display:none}) still keeps that rule from applying, on main and here: filed as #684. It errs toward no finding, and fixing it changes results on ordinary stylesheets, so it needs its own corpus check.Agent skill: no change needed (rule id, options and output shape are unchanged).
Closes #679