diff --git a/platform/npm/package.json b/platform/npm/package.json index 774b32a37..dd46f941a 100644 --- a/platform/npm/package.json +++ b/platform/npm/package.json @@ -1,6 +1,6 @@ { "name": "@gorhill/ubo-core", - "version": "0.1.10", + "version": "0.1.11", "description": "To create a working instance of uBlock Origin's static network filtering engine", "type": "module", "main": "index.js", diff --git a/platform/npm/tests/snfe.js b/platform/npm/tests/snfe.js index 0ce13a036..f45969502 100644 --- a/platform/npm/tests/snfe.js +++ b/platform/npm/tests/snfe.js @@ -232,6 +232,24 @@ describe('SNFE', () => { await engine.deserialize(serialized); }); }); + + + describe('Filter matching', () => { + beforeEach(async () => { + engine = await module.StaticNetFilteringEngine.create(); + }); + + it('should match block-important pure-hostname filter', async () => { + await engine.useLists([ + { name: 'test', raw: '@@||example.com^\n||example.com^$important' }, + ]); + engine.matchRequest({ + originURL: 'https://www.example.com/', + type: 'main_frame', + url: 'https://www.example.com/', + }); + }); + }); }); } }); diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index f3fee435d..a9aec2a9b 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -3067,6 +3067,7 @@ class FilterCompiler { break; case this.parser.OPTTokenImportant: if ( this.action === AllowAction ) { return false; } + this.optionUnitBits |= this.IMPORTANT_BIT; this.action = BlockImportant; break; // Used by Adguard: @@ -3574,14 +3575,15 @@ class FilterCompiler { } } -FilterCompiler.prototype.DOMAIN_BIT = 0b00000001; -FilterCompiler.prototype.DENYALLOW_BIT = 0b00000010; -FilterCompiler.prototype.HEADER_BIT = 0b00000100; -FilterCompiler.prototype.STRICT_PARTY_BIT = 0b00001000; -FilterCompiler.prototype.CSP_BIT = 0b00010000; -FilterCompiler.prototype.QUERYPRUNE_BIT = 0b00100000; -FilterCompiler.prototype.REDIRECT_BIT = 0b01000000; -FilterCompiler.prototype.NOT_TYPE_BIT = 0b10000000; +FilterCompiler.prototype.DOMAIN_BIT = 0b000000001; +FilterCompiler.prototype.DENYALLOW_BIT = 0b000000010; +FilterCompiler.prototype.HEADER_BIT = 0b000000100; +FilterCompiler.prototype.STRICT_PARTY_BIT = 0b000001000; +FilterCompiler.prototype.CSP_BIT = 0b000010000; +FilterCompiler.prototype.QUERYPRUNE_BIT = 0b000100000; +FilterCompiler.prototype.REDIRECT_BIT = 0b001000000; +FilterCompiler.prototype.NOT_TYPE_BIT = 0b010000000; +FilterCompiler.prototype.IMPORTANT_BIT = 0b100000000; FilterCompiler.prototype.FILTER_OK = 0; FilterCompiler.prototype.FILTER_INVALID = 1;