1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-20 01:12:38 +01:00

[mv3] Do not merge rules with errors

Related issue:
- https://github.com/uBlockOrigin/uBOL-issues/issues/10#issuecomment-1304822579
This commit is contained in:
Raymond Hill 2022-11-06 11:21:02 -05:00
parent 77e1af790b
commit 6574ede152
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 12 additions and 4 deletions

View File

@ -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.

View File

@ -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, []);