RESOLVED INVALID 167423
Rules with type=ignore-previous-rules are not applied to rules with `url-filter: *`
https://bugs.webkit.org/show_bug.cgi?id=167423
Summary Rules with type=ignore-previous-rules are not applied to rules with `url-filt...
Andrey Meshkov
Reported 2017-01-25 10:07:15 PST
#### Steps to reproduce 1. Register a content blocker with the following content: ``` [ { "trigger": { "url-filter": ".*" }, "action": { "type": "css-display-none", "selector": "img" } }, { "trigger": { "url-filter": "^https?://([^/]*\\.)?yahoo\\.com[/:&?]?", "resource-type": [ "document" ] }, "action": { "type": "ignore-previous-rules" } } ] ``` 2. Open yahoo.com #### Expected result All images are visible #### Actual result All images are hidden #### Explanation According to the [WebKit code](https://trac.webkit.org/browser/trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp#L76), `universalWithDomains` and `universalWithoutDomains` rules have higher priority. So, despite that the problematic rule precedes exception rule, it is not ignored.
Attachments
Radar WebKit Bug Importer
Comment 1 2017-01-27 13:54:39 PST
Alex Christensen
Comment 2 2017-06-29 12:36:15 PDT
I think what is happening in this case is the main resource is being loaded and the main resource is correctly ignoring previous rules and not applying the css-display-none rule. Any sub resource that is loaded that is not a document from yahoo.com would then trigger the first rule but not the ignore-previous-rules, thus hiding the images. This behaves correctly.
Andrey Meshkov
Comment 3 2017-06-29 13:02:49 PDT
> Any sub resource that is loaded that is not a document from yahoo.com would then trigger the first rule but not the ignore-previous-rules, thus hiding the images. I don't get it, how is that possible that "css-display-none" rule is applied to a non-document? I mean aren't stylesheets supposed to work in the context of a document only? Moreover, if I replace "url-filter": ".*" with "url-filter": "^http.*", content blocker starts working properly (all images are visible): ``` [ { "trigger": { "url-filter": "^http.*", }, "action": { "type": "css-display-none", "selector": "img" } }, { "trigger": { "url-filter": "^https?://([^/]*\\.)?yahoo\\.com[/:&?]?", "resource-type": [ "document" ] }, "action": { "type": "ignore-previous-rules" } } ] ```
Alex Christensen
Comment 4 2017-06-29 13:32:16 PDT
Your example in comment 3 doesn't hide images because it is invalid JSON and fails to compile. If you remove the , at the end of "^http.*", then it will successfully compile and behave correctly by hiding images because the triggers fire on sub resource loads. This is how the feature works. It behaves correctly.
Manish Jethani
Comment 5 2017-07-15 02:59:49 PDT
I've definitely run into this issue. Consider this rule set: [ { "trigger": { "url-filter": "^https?://" }, "action": { "type": "css-display-none", "selector": ".sponsored-container-bottom" } }, { "trigger": { "url-filter": "^https?://([^/]+\\.)?walmart\\.com" }, "action": { "type": "ignore-previous-rules" } } ] The first rule should hide any element with the class "sponsored-container-bottom" on any URL beginning with http:// or https:// The second rule, which only applies to walmart.com and subdomains, should disable the first rule. You can try this out on the following URL: https://www.walmart.com/search/?query=car%20rental%20cologne It does not work. Here's the Adblock Plus issue for more details: https://issues.adblockplus.org/ticket/5345 Am I misunderstanding how ignore-previous-rules is supposed to work?
Note You need to log in before you can comment on or make changes to this bug.