From 6574ede152ac571587454167ded34a1877f73c09 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 6 Nov 2022 11:21:02 -0500 Subject: [PATCH] [mv3] Do not merge rules with errors Related issue: - https://github.com/uBlockOrigin/uBOL-issues/issues/10#issuecomment-1304822579 --- platform/mv3/extension/js/ruleset-manager.js | 12 ++++++++---- src/js/static-net-filtering.js | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/platform/mv3/extension/js/ruleset-manager.js b/platform/mv3/extension/js/ruleset-manager.js index d37cae12d..56899e6c3 100644 --- a/platform/mv3/extension/js/ruleset-manager.js +++ b/platform/mv3/extension/js/ruleset-manager.js @@ -131,18 +131,22 @@ async function updateRegexRules() { // Collate results const results = await Promise.all(toCheck); const newRules = []; + const rejectedRegexRules = []; for ( let i = 0; i < allRules.length; i++ ) { const rule = allRules[i]; const result = results[i]; if ( result instanceof Object && result.isSupported ) { newRules.push(rule); } else { - //console.info(`${result.reason}: ${rule.condition.regexFilter}`); + rejectedRegexRules.push(rule); } } - console.info( - `Rejected regex filters: ${allRules.length-newRules.length} out of ${allRules.length}` - ); + if ( rejectedRegexRules.length !== 0 ) { + console.info( + 'Rejected regexes:', + rejectedRegexRules.map(rule => rule.condition.regexFilter) + ); + } // Add validated regex rules to dynamic ruleset without affecting rules // outside regex rules realm. diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index e36e9ab97..b1742d1d0 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -4175,6 +4175,9 @@ FilterContainer.prototype.dnrFromCompiled = function(op, context, ...args) { } // Merge rules where possible by merging arrays of a specific property. + // + // https://github.com/uBlockOrigin/uBOL-issues/issues/10#issuecomment-1304822579 + // Do not merge rules which have errors. const mergeRules = (rulesetMap, mergeTarget) => { const mergeMap = new Map(); const sorter = (_, v) => { @@ -4216,6 +4219,7 @@ FilterContainer.prototype.dnrFromCompiled = function(op, context, ...args) { } }; for ( const [ id, rule ] of rulesetMap ) { + if ( rule._error !== undefined ) { continue; } const hash = ruleHasher(rule, mergeTarget); if ( mergeMap.has(hash) === false ) { mergeMap.set(hash, []);