Skip to content

Commit a86b469

Browse files
committed
improve subdomain checking with $third-party option
fixes minbrowser#1406
1 parent e8565c0 commit a86b469

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ext/abp-filter-parser-modified/abp-filter-parser.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,15 @@ function matchOptions (filterOptions, input, contextParams, currentHost) {
455455
subdomains are also considered "same origin hosts" for the purposes of thirdParty and domain list checks
456456
see https://adblockplus.org/filter-cheatsheet#options:
457457
"The page loading it comes from example.com domain (for example example.com itself or subdomain.example.com) but not from foo.example.com or its subdomains"
458+
459+
Additionally, subdomain matches are bidrectional, i.e. a request for "a.b.com" on "b.com" and a request for "b.com" on "a.b.com" are both first-party
458460
*/
459-
if (filterOptions.thirdParty && isSameOriginHost(contextParams.domain, currentHost)) {
461+
462+
if (filterOptions.thirdParty && (isSameOriginHost(contextParams.domain, currentHost) || isSameOriginHost(currentHost, contextParams.domain))) {
460463
return false
461464
}
462465

463-
if (filterOptions.notThirdParty && !isSameOriginHost(contextParams.domain, currentHost)) {
466+
if (filterOptions.notThirdParty && !(isSameOriginHost(contextParams.domain, currentHost) || isSameOriginHost(currentHost, contextParams.domain))) {
464467
return false
465468
}
466469

0 commit comments

Comments
 (0)