domain modifier update

This commit is contained in:
Vasily Bagirov 2021-07-01 20:04:19 +03:00
parent a997776428
commit fb3f985c05
2 changed files with 39 additions and 10 deletions

View File

@ -333,13 +333,28 @@ If you want the rule not to be applied to certain domains, start a domain name w
* `||baddomain.com^$domain=~example.org` — a rule to block requests that match the specified mask, and are sent from any domain except `example.org` or it's subdomains.
* `||baddomain.com^$domain=example.org|~foo.example.org` — this rule blocks requests that are sent from `example.org` and all it's subdomains, except the subdomain `foo.example.org`.
###### `domain` and requests with `document` type
###### `domain` modifier matching target domain
When a request has `document` type, rules with `domain` modifier behave differently. In the following examples it's implied that requests are sent from `http://example.org/page` (the referrer), and the target URL is `http://targetdomain.com/page`.
In some cases the `$domain` modifier can match not only the referer domain, but also the target domain. This happens when all of the following is true:
1) The request has `document` type
2) The rule's pattern doesn't match any particular domain(s)
3) The rule's pattern doesn't contain regular expressions
When all these conditions are met, the `domain` modifier will match both the referer doman **and** the target domain.
**Examples:**
* `*$cookie,domain=example.org|example.com` will block cookies for all requests to and from `example.org` and `example.com`.
* `*$document,domain=example.org|example.com` will block all requests to and from `example.org` and `example.com`.
In the following examples it's implied that requests are sent from `http://example.org/page`(the referer) and the target URL is `http://targetdomain.com/page`.
* `page$domain=example.org` will be matched, as it matches the referer domain.
* `page$domain=targetdomain.com` will be matched, as it matches the target domain but satisfies all requirements mentioned above.
* `||page^$domain=targetdomain.com` will not be matched, as the pattern `||page^` matches specific domains.
* `/banner\d+/$domain=targetdomain.com` will not be matched as it contains a regular expression.
* `||page^$domain=example.org` will be matched, as it matches the referrer.
* `||page^$domain=~example.org` will not be matched, as it explicitly excludes `example.org`.
* `||page^$domain=targetdomain.com` will be matched, as it matches the target URL. This will not be true for all other types of requests.
<a id="third-party-modifier"></a>
##### **`third-party`**

View File

@ -335,13 +335,27 @@ pattern = "/" regexp "/"
* `||baddomain.com^$domain=~example.org` — правило для блокировки запросов, которые соответствуют указанной маске, и отправленных с любого домена, кроме `example.org` и его поддоменов.
* `||baddomain.com^$domain=example.org|~foo.example.org` — в данном примере правило будет соответствовать запросам, отправленным с домена `example.org` и всех его поддоменов, кроме поддомена `foo.example.org`.
###### `domain` и запросы с типом `document`
###### Когда `domain` соответствует целевому домену
Когда запрос имеет тип `document`, правила с модификатором `domain` ведут себя иначе. В следующих примерах предполагается, что запросы посылаются с `http://example.org/page` (реферер), а целевой URL — `http://targetdomain.com/page`.
В некоторых случаях модификатор `$domain` может соответствовать не только домену-рефереру, но и целевому домену. Это происходит в случае, когда всё из перечисленного верно:
* Правило `||page^$domain=example.org` сработает, поскольку под него подпадает реферер запроса.
* Правило `||page^$domain=~example.org` не сработает, поскольку оно явно исключает `example.org`.
* Правило `||page^$domain=targetdomain.com` сработает, поскольку под него подпадает целевой URL. Это не так для всех остальных типов запросов.
1) Запрос имеет тип `document`
2) Паттерн правила не соответствует какому-либо или каким-либо конкретным доменам
3) Паттерн правила не содержит регулярных выражений
Если все условия выполнены, модификатор `domain` будет соответствовать как рефереру, так и целевому домену.
**Примеры:**
* `*$cookie,domain=example.org|example.com` заблокирует cookies для всех запросов от и к `example.org` и `example.com`.
* `*$document,domain=example.org|example.com` заблокирует все запросы от и к `example.org` и `example.com`.
В следующих примерах предполагается, что запросы отправляются от `http://example.org/page`(реферер), а целевой URL - `http://targetdomain.com/page`.
* `page$domain=example.org` сработает, так как соответствует рефереру.
* `page$domain=targetdomain.com` сработает, так как соответствует целевому домену, но выполнены все условия, перечисленные выше.
* `||page^$domain=targetdomain.com` не сработает, поскольку паттерн `||page^` указывает на конкретные домены.
* `/banner\d+/$domain=targetdomain.com` не сработает, поскольку правило содержит регулярное выражение.
<a id="third-party-modifier"></a>