From 1d1490523d2e9d9621be67bbe1911de76bbc7c2a Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 30 Apr 2025 08:50:45 -0400 Subject: [PATCH] [mv3] Fix incorrect DNR priority for redirect/important filters --- src/js/static-net-filtering.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index d08db1e51..68364c80c 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -762,6 +762,10 @@ class FilterImportant { return filterDataAlloc(args[0]); } + static dnrFromCompiled(args, rule) { + rule.__important = true; + } + static keyFromArgs() { } @@ -4446,10 +4450,8 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar const realms = new Map([ [ BLOCK_REALM, { type: 'block', priority: 10 } ], - [ BLOCK_REALM | IMPORTANT_REALM, { type: 'block', priority: 40 } ], [ ALLOW_REALM, { type: 'allow', priority: 30 } ], [ REDIRECT_REALM, { type: 'redirect', priority: 11 } ], - [ REDIRECT_REALM | IMPORTANT_REALM, { type: 'redirect', priority: 41 } ], [ REMOVEPARAM_REALM, { type: 'removeparam', priority: 0 } ], [ CSP_REALM, { type: 'csp', priority: 0 } ], [ PERMISSIONS_REALM, { type: 'permissions', priority: 0 } ], @@ -4510,6 +4512,13 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar } } + // Adjust `important` priority + for ( const rule of ruleset ) { + if ( rule.__important !== true ) { continue; } + if ( rule.priority === undefined ) { continue; } + rule.priority += 30; + } + // Collect generichide filters const generichideExclusions = []; const generichideInclusions = [];