-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement cosmetic filtering #47
Conversation
ce04638
to
fc98c6c
Compare
a7026a0
to
f453fb3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - a few small nits that would be good to address, but not a blocker, marking approved
src/filters/cosmetic.rs
Outdated
/// | ||
/// See the `matches_str` test helper function for an example of how to convert hostnames and | ||
/// domains into the appropriate hash lists. | ||
pub fn matches(&self, request_entities: &[Hash], request_hostnames: &[Hash]) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method makes sense, but not seeing where it gets used besides tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was from before I started storing rules keyed by hostname.
It might still be useful for some kind of logging or dashboard? Should I just remove it altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove it, if we want it again we can probably do better
add CosmeticFilter fields add cosmetic mask fields
f453fb3
to
f5df13f
Compare
add tests for parsing cosmetic rules with simple selectors implement is_simple_*selector methods Finish cosmetic filter parsing implementation The only thing missing from here is CSS rule validation. Generally, a DOM is used for that purpose in Javascript-based implementations.
break rule parsing after '#' separator into separate function remove support for `script:inject()` It appears that `script:inject()` is no longer in use; the newer `+js()` syntax is preferred. Ref: https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#scriptlet-injection
reduce code duplication in tests add tests for hostname parsing add tests for href selectors The Cliqz implementation does not flag `href$=` selectors, so I've left those unflagged as well. add tests for entities as well as fixes for associated logical errors add tests for injected scripts add style specifier tests add tests for unicode and unsupported syntax disallow unhide and script inject rules without hostname constraints prevent generic style rules prohibit double-negated cosmetic filters remove href flag from cosmetic filters
Rather than pulling in an entire CSS styling library as a dependency, this ensures that the syntax of supplied CSS selectors is valid, without concern for the textual content of individual tokens. As new pseudo-selectors are added to the W3C spec, this implementation should still function as intended. add tests for bad CSS selector inputs protect against urls appearing in `:style()` filters See uBlockOrigin/uBlock-issues#668
a3a20d0
to
3ee7cfe
Compare
add tests for matching util functions add tests for cosmetic filter matching use iterators instead of loops during matching document cosmetic filter rule matching functions rename hash lists in cosmetic filter matching function update matching algorithm for batch queries simplify test matching implementation
add selector to key convertion tests Currently, `escaped_characters` and `escape_codes` fail because there is no handling for these at the moment.
add key to existing tests
store complex selector strings instead of entire rules add function to allow retrieving rules for new classes and ids
…esheet harden CosmeticFilterCache thread safety across FFI
add struct for keeping track of exceptions per-hostname add type for returning information specific to a hostname
…t injects tests for exceptions and base stylesheet fix hidden_generic_rule implementation add tests for hidden generic rules
add tests for style and script inject exceptions
tests for class and id stylesheets with exceptions
return a single injectable script instead of a Vec
3ee7cfe
to
a2045a6
Compare
Closes #38.