mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Fix reverse lookup of generic cosmetic filters
Related feedback:
- 26594fb902 (commitcomment-92413254)
This commit is contained in:
parent
96e75770c2
commit
f1b19d5115
2 changed files with 4 additions and 28 deletions
|
@ -737,22 +737,17 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) {
|
|||
|
||||
const selectorsSet = new Set();
|
||||
const hashes = [];
|
||||
const safeOnly = request.safeOnly === true;
|
||||
for ( const hash of request.hashes ) {
|
||||
const bucket = this.lowlyGeneric.get(hash);
|
||||
if ( bucket === undefined ) { continue; }
|
||||
for ( const selector of bucket.split(',\n') ) {
|
||||
if ( safeOnly && selector === keyFromSelector(selector) ) { continue; }
|
||||
selectorsSet.add(selector);
|
||||
}
|
||||
hashes.push(hash);
|
||||
}
|
||||
|
||||
if ( request.safeOnly ) {
|
||||
for ( const selector of selectorsSet ) {
|
||||
if ( selector !== keyFromSelector(selector) ) { continue; }
|
||||
selectorsSet.delete(selector);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply exceptions: it is the responsibility of the caller to provide
|
||||
// the exceptions to be applied.
|
||||
const excepted = [];
|
||||
|
|
|
@ -183,33 +183,14 @@ const fromExtendedFilter = function(details) {
|
|||
const filterType = fargs[0];
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/2763
|
||||
if (
|
||||
filterType >= 0 &&
|
||||
filterType <= 5 &&
|
||||
details.ignoreGeneric
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if ( filterType === 0 && details.ignoreGeneric ) { continue; }
|
||||
|
||||
// Do not confuse cosmetic filters with HTML ones.
|
||||
if ( (filterType === 64) !== isHtmlFilter ) { continue; }
|
||||
|
||||
switch ( filterType ) {
|
||||
// Lowly generic cosmetic filters
|
||||
case 0: // simple id-based
|
||||
if ( exception ) { break; }
|
||||
if ( fargs[1] !== selector.slice(1) ) { break; }
|
||||
if ( selector.charAt(0) !== '#' ) { break; }
|
||||
found = prefix + selector;
|
||||
break;
|
||||
case 2: // simple class-based
|
||||
if ( exception ) { break; }
|
||||
if ( fargs[1] !== selector.slice(1) ) { break; }
|
||||
if ( selector.charAt(0) !== '.' ) { break; }
|
||||
found = prefix + selector;
|
||||
break;
|
||||
case 1: // complex id-based
|
||||
case 3: // complex class-based
|
||||
case 0:
|
||||
if ( exception ) { break; }
|
||||
if ( fargs[2] !== selector ) { break; }
|
||||
found = prefix + selector;
|
||||
|
|
Loading…
Reference in a new issue