Parse AdGuard #$# CSS injection as style/remove actions#685
Closed
ryanbr wants to merge 1 commit into
Closed
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 brave#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.
Collaborator
Author
|
Superseded by #686, opened from an internal branch so the Performance CI step can post its results comment. The failure here was a fork-PR token permission issue ( |
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(#$?#).