Skip to content

Commit dcc89af

Browse files
Merge pull request #677 from AdguardTeam/feature/AG-31991
Remove complicated heuristics for $domain modifier
2 parents f3a4cfd + 8084108 commit dcc89af

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

docs/general/ad-filtering/create-own-filters.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -564,40 +564,24 @@ If you want the rule not to be applied to certain domains, start a domain name w
564564

565565
**`$domain` modifier matching target domain:**
566566

567-
In some cases the `$domain` modifier can match not only the referrer domain, but also the target domain. This happens when all the following conditions are met:
567+
In some cases the `$domain` modifier can match not only the referrer domain, but also the target domain.
568568

569-
1. The request has the `document` content type
570-
1. The rule pattern does not match any particular domains
571-
1. The rule pattern does not contain regular expressions
572-
1. The `$domain` modifier contains only excluded domains, e.g. `$domain=~example.org|~example.com`
569+
This happens when the rule has one of the following modifiers: [`$cookie`](#cookie-modifier), [`$csp`](#csp-modifier), [`$permissions`](#permissions-modifier), [`$removeparam`](#removeparam-modifier).
573570

574-
The following predicate should be satisfied to perform a target domain matching:
575-
576-
```text
577-
1 AND ((2 AND 3) OR 4)
578-
```
579-
580-
That is, if the modifier `$domain` contains only excluded domains, then the rule does not need to meet the second and third conditions to match the target domain against the modifier `$domain`.
581-
582-
If some of the conditions above are not met but the rule contains [`$cookie`](#cookie-modifier) or [`$csp`](#csp-modifier) modifier, the target domain will still be matched.
583-
584-
If the referrer matches a rule with `$domain` that explicitly excludes the referrer domain, then the rule will not be applied even if the target domain also matches the rule. This affects rules with [`$cookie`](#cookie-modifier) and [`$csp`](#csp-modifier) modifiers, too.
571+
These modifiers will not be applied if the referrer matches a rule with `$domain` that explicitly excludes the referrer domain, even if the target domain also matches the rule.
585572

586573
**Examples**
587574

588575
- `*$cookie,domain=example.org|example.com` will block cookies for all requests to and from `example.org` and `example.com`.
589-
- `*$document,domain=example.org|example.com` will block all requests to and from `example.org` and `example.com`.
576+
- `*$document,domain=example.org|example.com` will block requests only from `example.org` and `example.com`, but not to them.
590577

591578
In the following examples it is implied that requests are sent from `http://example.org/page` (the referrer) and the target URL is `http://targetdomain.com/page`.
592579

593580
- `page$domain=example.org` will be matched, as it matches the referrer domain.
594-
- `page$domain=targetdomain.com` will be matched, as it matches the target domain and satisfies all requirements mentioned above.
595-
- `||*page$domain=targetdomain.com` will not be matched, as the pattern `||*page` may match specific domains,
596-
e.g. `example.page`.
581+
- `page$domain=targetdomain.com` will not be matched because it does not match the referrer domain.
597582
- `||*page$domain=targetdomain.com,cookie` will be matched because the rule contains `$cookie` modifier
598583
despite the pattern `||*page` may match specific domains.
599-
- `/banner\d+/$domain=targetdomain.com` will not be matched as it contains a regular expression.
600-
- `page$domain=targetdomain.com|~example.org` will not be matched because the referrer domain is explicitly excluded.
584+
- `page$domain=targetdomain.com|~example.org,cookie` will not be matched because the referrer domain is explicitly excluded.
601585

602586
##### `$domain` modifier limitations {#domain-modifier-limitations}
603587

0 commit comments

Comments
 (0)