mirror of https://github.com/gorhill/uBlock.git
[mv3] Also log salvaged rules using entity-based domains
Some filters with entity-based domain option can be salvaged when there are non-entity-based domain option, but since we are throwing away the entity-based entries, we are only partially converting to DNR. This commit will log a warning about this in log.txt. Before this commit, only non-salvageable filters were logged.
This commit is contained in:
parent
86ba04dd68
commit
ea15cef524
|
@ -267,6 +267,12 @@ async function processNetworkFilters(assetDetails, network) {
|
|||
|
||||
const plainGood = rules.filter(rule => isGood(rule) && isRegex(rule) === false);
|
||||
log(`\tPlain good: ${plainGood.length}`);
|
||||
log(plainGood
|
||||
.filter(rule => Array.isArray(rule._warning))
|
||||
.map(rule => rule._warning.map(v => `\t\t${v}`))
|
||||
.join('\n'),
|
||||
true
|
||||
);
|
||||
|
||||
const regexes = rules.filter(rule => isGood(rule) && isRegex(rule));
|
||||
log(`\tMaybe good (regexes): ${regexes.length}`);
|
||||
|
|
|
@ -673,6 +673,11 @@ const dnrAddRuleError = (rule, msg) => {
|
|||
rule._error.push(msg);
|
||||
};
|
||||
|
||||
const dnrAddRuleWarning = (rule, msg) => {
|
||||
rule._warning = rule._warning || [];
|
||||
rule._warning.push(msg);
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
Filter classes
|
||||
|
@ -4385,8 +4390,9 @@ FilterContainer.prototype.dnrFromCompiled = function(op, context, ...args) {
|
|||
hn => hn.endsWith('.*') === false
|
||||
);
|
||||
if ( domains.length === 0 ) {
|
||||
dnrAddRuleError(rule, `Could not salvage rule with only entity-based domain= option: ${rule.condition.initiatorDomains.join('|')}`);
|
||||
dnrAddRuleError(rule, `Can't salvage rule with only entity-based domain= option: ${rule.condition.initiatorDomains.join('|')}`);
|
||||
} else {
|
||||
dnrAddRuleWarning(rule, `Salvaged rule by ignoring ${rule.condition.initiatorDomains.length - domains.length} entity-based domain= option: ${rule.condition.initiatorDomains.join('|')}`);
|
||||
rule.condition.initiatorDomains = domains;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue