Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement cosmetic filtering #47
Merged
Conversation
Merged
a7026a0
to
f453fb3
|
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 { |
This comment has been minimized.
This comment has been minimized.
AndriusA
Nov 18, 2019
Collaborator
method makes sense, but not seeing where it gets used besides tests
This comment has been minimized.
This comment has been minimized.
antonok-edm
Nov 18, 2019
Author
Collaborator
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?
This comment has been minimized.
This comment has been minimized.
add CosmeticFilter fields add cosmetic mask fields
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
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
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.
antonok-edm commentedAug 29, 2019
Closes #38.