diff --git a/packages/tsurlfilter/CHANGELOG.md b/packages/tsurlfilter/CHANGELOG.md index 8b0da38bb..011426579 100644 --- a/packages/tsurlfilter/CHANGELOG.md +++ b/packages/tsurlfilter/CHANGELOG.md @@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +## Unreleased + +### Fixed + +- The exception `$domain=~` filter rule is not working properly [AdguardBrowserExtension#2912]. + +[AdguardBrowserExtension#2912]: https://github.com/AdguardTeam/AdguardBrowserExtension/issues/2912 + ## [3.0.2] - 2024-08-29 ### Changed diff --git a/packages/tsurlfilter/src/rules/network-rule.ts b/packages/tsurlfilter/src/rules/network-rule.ts index 6ae46d3fd..724d1cf6e 100644 --- a/packages/tsurlfilter/src/rules/network-rule.ts +++ b/packages/tsurlfilter/src/rules/network-rule.ts @@ -755,7 +755,7 @@ export class NetworkRule implements rule.IRule { * In some cases the $domain modifier can match not only the referrer domain, but also the target domain. * This happens when the following is true (1 AND ((2 AND 3) OR 4): * - * 1) The request has document type + * 1) The request has $document request type (not subdocument) * 2) The rule's pattern doesn't match any particular domain(s) * 3) The rule's pattern doesn't contain regular expressions * 4) The $domain modifier contains only excluded domains (e.g., $domain=~example.org|~example.com) @@ -771,8 +771,7 @@ export class NetworkRule implements rule.IRule { const { domainModifier } = this; - const isDocumentType = request.requestType === RequestType.Document - || request.requestType === RequestType.SubDocument; + const isDocumentType = request.requestType === RequestType.Document; const hasOnlyExcludedDomains = !domainModifier.hasPermittedDomains() && domainModifier.hasRestrictedDomains(); diff --git a/packages/tsurlfilter/test/engine/network-engine.test.ts b/packages/tsurlfilter/test/engine/network-engine.test.ts index f6aae891e..167c9fc75 100644 --- a/packages/tsurlfilter/test/engine/network-engine.test.ts +++ b/packages/tsurlfilter/test/engine/network-engine.test.ts @@ -217,18 +217,6 @@ describe('Test $domain modifier semantics', () => { ); }); - it('will match request url host - subdocument', () => { - const request = new Request('http://check.com/path', 'http://test.com/', RequestType.SubDocument); - const result = engine.match(request); - - expect(result).toBeTruthy(); - expect( - getRuleSourceIndex(result!.getIndex(), processed.sourceMap), - ).toBe( - getRawRuleIndex(processed.rawFilterList, rule), - ); - }); - it('checks request type Document is required', () => { const request = new Request('http://check.com/path', 'http://test.com/', RequestType.Image); const result = engine.match(request); diff --git a/packages/tsurlfilter/test/rules/network-rule.test.ts b/packages/tsurlfilter/test/rules/network-rule.test.ts index a066b4cb9..908d658ea 100644 --- a/packages/tsurlfilter/test/rules/network-rule.test.ts +++ b/packages/tsurlfilter/test/rules/network-rule.test.ts @@ -967,11 +967,6 @@ describe('NetworkRule.match', () => { request = new Request('https://example.org/', 'https://example.com/', RequestType.Document); expect(rule.match(request)).toEqual(true); - // Match request url host - rule = createNetworkRule('$domain=example.org', 0); - request = new Request('https://example.org/', 'https://example.com/', RequestType.SubDocument); - expect(rule.match(request)).toEqual(true); - // Document or Subdocument only rule = createNetworkRule('$domain=example.org', 0); request = new Request('https://example.org/', 'https://example.com/', RequestType.Image);