mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Fix regression with highly generic cosmetic filters CSS files
Regression from:
56ba93700c
Related feedback:
https://old.reddit.com/r/uBlockOrigin/comments/1mi8fd6/ublock_origin_lite_for_ios/n725s6l/
This commit is contained in:
parent
e390822930
commit
1e0c64076f
1 changed files with 29 additions and 23 deletions
|
|
@ -221,42 +221,48 @@ function addExtendedToDNR(context, parser) {
|
|||
});
|
||||
return;
|
||||
}
|
||||
let details = context.specificCosmeticFilters.get(compiled);
|
||||
let isGeneric = true;
|
||||
const matches = [];
|
||||
const excludeMatches = [];
|
||||
for ( const { hn, not, bad } of parser.getExtFilterDomainIterator() ) {
|
||||
if ( bad ) { continue; }
|
||||
if ( not && exception ) { continue; }
|
||||
isGeneric = false;
|
||||
// TODO: Support regex- and path-based entries
|
||||
if ( isRegexOrPath(hn) ) { continue; }
|
||||
if ( details === undefined ) {
|
||||
context.specificCosmeticFilters.set(compiled, details = {});
|
||||
if ( not || exception ) {
|
||||
excludeMatches.push(hn);
|
||||
} else if ( hn !== '*' ) {
|
||||
matches.push(hn);
|
||||
}
|
||||
if ( compiled.startsWith('{') === false ) {
|
||||
details.key = keyFromSelector(compiled);
|
||||
}
|
||||
if ( exception || not ) {
|
||||
if ( details.excludeMatches === undefined ) {
|
||||
details.excludeMatches = [];
|
||||
}
|
||||
details.excludeMatches.push(hn);
|
||||
continue;
|
||||
}
|
||||
// This should not happen
|
||||
if ( matches.length === 0 && excludeMatches.length === 0 ) { return; }
|
||||
// Only negated hostnames => generic cosmetic filter
|
||||
if ( exception === false && matches.length === 0 && excludeMatches.length !== 0 ) {
|
||||
addGenericCosmeticFilter(context, compiled, false);
|
||||
}
|
||||
const key = compiled.startsWith('{') === false && keyFromSelector(compiled);
|
||||
let details = context.specificCosmeticFilters.get(compiled);
|
||||
if ( details === undefined ) {
|
||||
context.specificCosmeticFilters.set(compiled, details = {});
|
||||
if ( key ) {
|
||||
details.key = key;
|
||||
}
|
||||
}
|
||||
if ( matches.length ) {
|
||||
if ( details.matches === undefined ) {
|
||||
details.matches = [];
|
||||
}
|
||||
if ( details.matches.includes('*') ) { continue; }
|
||||
if ( hn === '*' ) {
|
||||
if ( matches.includes('*') ) {
|
||||
details.matches = [ '*' ];
|
||||
continue;
|
||||
} else if ( details.matches.includes('*') === false ) {
|
||||
details.matches.push(...matches);
|
||||
}
|
||||
details.matches.push(hn);
|
||||
}
|
||||
if ( details === undefined ) { return; }
|
||||
if ( exception ) { return; }
|
||||
if ( compiled.startsWith('{') ) { return; }
|
||||
if ( isGeneric ) {
|
||||
addGenericCosmeticFilter(context, compiled, false);
|
||||
if ( excludeMatches.length ) {
|
||||
if ( details.excludeMatches === undefined ) {
|
||||
details.excludeMatches = [];
|
||||
}
|
||||
details.excludeMatches.push(...excludeMatches);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue