From 43a883396d57e3311b2ef5f2fc228bd04117a3c1 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 13 Jun 2025 11:10:16 -0400 Subject: [PATCH] [mv3] Fix regression in handling `important` option Related issue: https://github.com/uBlockOrigin/uBOL-home/issues/368 --- src/js/static-net-filtering.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 96b972915..3c0d3f73f 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -4525,6 +4525,7 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar const realms = new Map([ [ BLOCK_REALM, { type: 'block', priority: 10 } ], [ ALLOW_REALM, { type: 'allow', priority: 30 } ], + [ BLOCK_REALM | IMPORTANT_REALM, { type: 'block', priority: 10 } ], [ REDIRECT_REALM, { type: 'redirect', priority: 11 } ], [ REMOVEPARAM_REALM, { type: 'removeparam', priority: 0 } ], [ CSP_REALM, { type: 'csp', priority: 0 } ], @@ -4532,7 +4533,7 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar [ URLTRANSFORM_REALM, { type: 'uritransform', priority: 0 } ], [ HEADERS_REALM, { type: 'block', priority: 10 } ], [ HEADERS_REALM | ALLOW_REALM, { type: 'allow', priority: 30 } ], - [ HEADERS_REALM | IMPORTANT_REALM, { type: 'allow', priority: 40 } ], + [ HEADERS_REALM | IMPORTANT_REALM, { type: 'allow', priority: 10 } ], [ URLSKIP_REALM, { type: 'urlskip', priority: 0 } ], ]); const partyness = new Map([ @@ -4556,6 +4557,7 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar 'other', ]); const ruleset = []; + const seen = new Set(); for ( const [ realmBits, realmDetails ] of realms ) { for ( const [ partyBits, partyName ] of partyness ) { for ( const typeName in typeNameToTypeValue ) { @@ -4579,12 +4581,16 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar rule.condition = rule.condition || {}; rule.condition.resourceTypes = [ typeName ]; } + const hash = JSON.stringify(rule); + if ( seen.has(hash) ) { continue; } + seen.add(hash); ruleset.push(rule); } } } } } + seen.clear(); // Adjust `important` priority for ( const rule of ruleset ) {