Parse AdGuard #$# CSS injection as style/remove actions#686
Open
ryanbr wants to merge 1 commit into
Open
Conversation
`#$#selector { ... }` (AdGuard CSS injection) was rejected outright as
unsupported syntax. Route it through the same brace-body parser used for
the uBO/ABP `##selector { ... }` form added in #678, producing a `Style`
or `remove:` action.
Only the style/remove form is handled — it always carries a `{ ... }`
body. ABP snippet injection also uses `#$#` but has no braces; those
produce no action and remain rejected. The extended `#$?#` and exception
`#@$#` forms fall out naturally via the existing `?`/`@` handlers.
There was a problem hiding this comment.
Rust Benchmark
Details
| Benchmark suite | Current: 77587df | Previous: 5d182e5 | Ratio |
|---|---|---|---|
rule-match-browserlike/brave-list |
2184625955 ns/iter (± 28173310) |
2241363322 ns/iter (± 47317273) |
0.97 |
rule-match-first-request/brave-list |
1194826 ns/iter (± 15325) |
1216052 ns/iter (± 6861) |
0.98 |
blocker_new/brave-list |
134582719 ns/iter (± 545998) |
138839767 ns/iter (± 844690) |
0.97 |
blocker_new/brave-list-deserialize |
27992332 ns/iter (± 261528) |
31752836 ns/iter (± 821884) |
0.88 |
memory-usage-final/brave-list-initial |
11355668 B/iter (± 0) |
11355668 B/iter (± 0) |
1 |
memory-usage-final/brave-list-1000-requests |
2612449 B/iter (± 0) |
2612449 B/iter (± 0) |
1 |
memory-usage-max/brave-list-initial/max |
63576475 B/iter (± 0) |
63576475 B/iter (± 0) |
1 |
memory-usage-alloc-count/brave-list-initial/alloc-count |
859963 allocs/iter (± 0) |
859963 allocs/iter (± 0) |
1 |
memory-usage-alloc-count/brave-list-1000-requests/alloc-count |
74018 allocs/iter (± 0) |
74018 allocs/iter (± 0) |
1 |
url_cosmetic_resources/brave-list |
188858 ns/iter (± 652) |
191870 ns/iter (± 955) |
0.98 |
cosmetic-class-id-match/brave-list |
3579896 ns/iter (± 966608) |
3552152 ns/iter (± 986336) |
1.01 |
This comment was automatically generated by workflow using github-action-benchmark.
boocmp
approved these changes
Jun 30, 2026
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.
Summary
AdGuard's
#$#CSS-injection syntax (e.g.businesshemden.com#$#.mnd-cookie-modal { display: none !important; }) was rejected outright asUnsupportedSyntax. This routes it through the same brace-body parser added in #678 for the uBO/ABP##selector { ... }form, producing aStyle(orremove:→Remove) action.Details
between_sharps.starts_with('$')branch now consumes the$and sets a flag instead of erroring. The existing?and leading-@handlers then cover the extended#$?#and exception#@$#forms with no extra code.#$#rule that produced no action. This is the key safety check: ABP snippet injection also uses#$#but has no{ ... }body (e.g.example.com#$#abort-on-property-read alert), and must stay unsupported rather than being misparsed as a plain CSS selector.#%#/#@%#(AdGuard JS/scriptlet) remain unsupported — scope is limited to the CSS style/remove form.Behavior change
Two existing assertions in
tests/unit/lists.rsthat expected#$#/#@$#to beUnsupportedSyntaxare updated to expect successful parsing — this is the intended contract change.Tests
cargo fmt --checkclean; full lib suite passes under both default andcss-validationfeatures. Addsadguard_css_injection(style, multi-class selector,remove:, ABP-snippet rejection, generic rejection) andadguard_css_injection_extended(#$?#).Supersedes #685 (that PR was opened from a fork, which makes the Performance CI step fail when it tries to post its results comment with a read-only token — no actual regression; all benchmark ratios were ≤ 1.00).