<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>167423</bug_id>
          
          <creation_ts>2017-01-25 10:07:15 -0800</creation_ts>
          <short_desc>Rules with type=ignore-previous-rules are not applied to rules with `url-filter: *`</short_desc>
          <delta_ts>2017-07-15 02:59:49 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrey Meshkov">am</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>am</cc>
    
    <cc>manish</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1269866</commentid>
    <comment_count>0</comment_count>
    <who name="Andrey Meshkov">am</who>
    <bug_when>2017-01-25 10:07:15 -0800</bug_when>
    <thetext>#### Steps to reproduce

1. Register a content blocker with the following content:
```
[
	{
		&quot;trigger&quot;: {
			&quot;url-filter&quot;: &quot;.*&quot;
		},
		&quot;action&quot;: {
			&quot;type&quot;: &quot;css-display-none&quot;,
			&quot;selector&quot;: &quot;img&quot;
		}
	},
	{
		&quot;trigger&quot;: {
			&quot;url-filter&quot;: &quot;^https?://([^/]*\\.)?yahoo\\.com[/:&amp;?]?&quot;,
			&quot;resource-type&quot;: [
				&quot;document&quot;
			]
		},
		&quot;action&quot;: {
			&quot;type&quot;: &quot;ignore-previous-rules&quot;
		}
	}
]
```

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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1270760</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-01-27 13:54:39 -0800</bug_when>
    <thetext>&lt;rdar://problem/30240549&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1324048</commentid>
    <comment_count>2</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2017-06-29 12:36:15 -0700</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1324064</commentid>
    <comment_count>3</comment_count>
    <who name="Andrey Meshkov">am</who>
    <bug_when>2017-06-29 13:02:49 -0700</bug_when>
    <thetext>&gt; 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&apos;t get it, how is that possible that &quot;css-display-none&quot; rule is applied to a non-document? I mean aren&apos;t stylesheets supposed to work in the context of a document only?

Moreover, if I replace &quot;url-filter&quot;: &quot;.*&quot; with &quot;url-filter&quot;: &quot;^http.*&quot;, content blocker starts working properly (all images are visible):
```
[
	{
		&quot;trigger&quot;: {
			&quot;url-filter&quot;: &quot;^http.*&quot;,
		},
		&quot;action&quot;: {
			&quot;type&quot;: &quot;css-display-none&quot;,
			&quot;selector&quot;: &quot;img&quot;
		}
	},
	{
		&quot;trigger&quot;: {
			&quot;url-filter&quot;: &quot;^https?://([^/]*\\.)?yahoo\\.com[/:&amp;?]?&quot;,
			&quot;resource-type&quot;: [
				&quot;document&quot;
			]
		},
		&quot;action&quot;: {
			&quot;type&quot;: &quot;ignore-previous-rules&quot;
		}
	}
]
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1324072</commentid>
    <comment_count>4</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2017-06-29 13:32:16 -0700</bug_when>
    <thetext>Your example in comment 3 doesn&apos;t hide images because it is invalid JSON and fails to compile.  If you remove the , at the end of &quot;^http.*&quot;, 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1329162</commentid>
    <comment_count>5</comment_count>
    <who name="Manish Jethani">manish</who>
    <bug_when>2017-07-15 02:59:49 -0700</bug_when>
    <thetext>I&apos;ve definitely run into this issue.

Consider this rule set:

  [
    {
      &quot;trigger&quot;: {
        &quot;url-filter&quot;: &quot;^https?://&quot;
      },
      &quot;action&quot;: {
        &quot;type&quot;: &quot;css-display-none&quot;,
        &quot;selector&quot;: &quot;.sponsored-container-bottom&quot;
      }
    },
    {
      &quot;trigger&quot;: {
        &quot;url-filter&quot;: &quot;^https?://([^/]+\\.)?walmart\\.com&quot;
      },
      &quot;action&quot;: {
        &quot;type&quot;: &quot;ignore-previous-rules&quot;
      }
    }
  ]

The first rule should hide any element with the class &quot;sponsored-container-bottom&quot; 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&apos;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?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>