<?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>207540</bug_id>
          
          <creation_ts>2020-02-11 06:34:45 -0800</creation_ts>
          <short_desc>Allow Content Blocker lists to contain both if/unless-domain and if/unless-top-url trigger fields</short_desc>
          <delta_ts>2020-03-19 16:52:00 -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>Other</version>
          <rep_platform>All</rep_platform>
          <op_sys>Unspecified</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>Enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kyle Hickinson">khickinson</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>beidson</cc>
    
    <cc>ggaren</cc>
    
    <cc>mjs</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1617356</commentid>
    <comment_count>0</comment_count>
    <who name="Kyle Hickinson">khickinson</who>
    <bug_when>2020-02-11 06:34:45 -0800</bug_when>
    <thetext>The current content blocker API fails to compile a list if you attempt to have a list that contains both the `if-domain` and `if-top-url` (or `unless-domain` and `unless-top-url`) url triggers, even if said triggers are not in the same rule.  For example, this list will fail to compile:


```
[
  {
    &quot;trigger&quot;: {
        &quot;url-filter&quot;: &quot;.*&quot;,
        &quot;resource-type&quot;: [&quot;image&quot;, &quot;style-sheet&quot;],
        &quot;unless-domain&quot;: [&quot;foo.com&quot;, &quot;bar.com&quot;]
    },
    &quot;action&quot;: {
      &quot;type&quot;: &quot;block&quot;
    }
  },
  {
    &quot;trigger&quot;: {
        &quot;url-filter&quot;: &quot;.*&quot;,
        &quot;resource-type&quot;: [&quot;script&quot;],
        &quot;unless-top-url&quot;: &quot;baz.com&quot;,
    },
    &quot;action&quot;: {
      &quot;type&quot;: &quot;block&quot;
    }
  }
]
```

These two rules are completely unrelated to each other, but WebKit will fail to compile this list because of the usage of both `unless-domain` and `unless-top-url` in the same file

This limitation isn&apos;t specified in the documentation around these triggers. The only thing the documentation specifies is that you cannot use `if-domain` and `unless-domain`, or `if-top-url` and `unless-top-url` in the same rule. 

I think the expected result is that these rules should be allowed to co-exist in the same list

rdar://FB7557901</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1617428</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-02-11 09:26:53 -0800</bug_when>
    <thetext>&lt;rdar://problem/59350914&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1620580</commentid>
    <comment_count>2</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2020-02-19 02:03:51 -0800</bug_when>
    <thetext>Seems like a bug (but I may be missing some reason this would be an intentional limitation).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1631917</commentid>
    <comment_count>3</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2020-03-19 16:52:00 -0700</bug_when>
    <thetext>This is intentional.  We want to limit the number of times we must run URLs through the finite state machine.  if-domain and unless-domain runs the domain of the top URL though the finite state machine.  if-top-url and unless-top-url run the whole top URL through the finite state machine.  If you want &quot;both&quot; then write a regular expression that, when run on the entire top URL, looks at the domain, like this:
&quot;unless-top-url&quot;: [&quot;.*://foo.com/&quot;, &quot;.*://bar.com/&quot;]</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>