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

Take into account simple selectors present in array of selectors

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1692
This commit is contained in:
Raymond Hill 2021-08-24 12:29:48 -04:00
parent 811a9be45f
commit 6dcd5df991
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -842,25 +842,26 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) {
const entry = this.lowlyGeneric[type]; const entry = this.lowlyGeneric[type];
const selectors = request[entry.canonical]; const selectors = request[entry.canonical];
if ( Array.isArray(selectors) === false ) { continue; } if ( Array.isArray(selectors) === false ) { continue; }
for ( const selector of selectors ) { for ( const identifier of selectors ) {
if ( entry.simple.has(selector) === false ) { continue; } if ( entry.simple.has(identifier) === false ) { continue; }
const bucket = entry.complex.get(selector); const bucket = entry.complex.get(identifier);
if ( bucket === undefined ) { if ( typeof bucket === 'string' ) {
if ( safeOnly ) { continue; }
const simpleSelector = entry.prefix + selector;
if ( previousHits.has(simpleSelector) ) { continue; }
simpleSelectors.add(simpleSelector);
continue;
}
if ( Array.isArray(bucket) === false ) {
if ( previousHits.has(bucket) ) { continue; } if ( previousHits.has(bucket) ) { continue; }
complexSelectors.add(bucket); complexSelectors.add(bucket);
continue; continue;
} }
for ( const selector of bucket ) { const simpleSelector = entry.prefix + identifier;
if ( previousHits.has(selector) ) { continue; } if ( Array.isArray(bucket) ) {
complexSelectors.add(selector); for ( const complexSelector of bucket ) {
if ( previousHits.has(complexSelector) ) { continue; }
if ( safeOnly && complexSelector === simpleSelector ) { continue; }
complexSelectors.add(complexSelector);
}
continue;
} }
if ( previousHits.has(simpleSelector) ) { continue; }
if ( safeOnly ) { continue; }
simpleSelectors.add(simpleSelector);
} }
} }