Fix reverse lookup of generic cosmetic exception filters

Reported internally.
This commit is contained in:
Raymond Hill 2020-06-11 07:18:45 -04:00
parent 89fcdc6a11
commit 681bd70116
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 16 additions and 22 deletions

View file

@ -510,7 +510,7 @@ FilterContainer.prototype.compileGenericUnhideSelector = function(
// hostnames). No distinction is made between declarative and
// procedural selectors, since they really exist only to cancel
// out other cosmetic filters.
writer.push([ 8, '', 0b01, compiled ]);
writer.push([ 8, '', 0b001, compiled ]);
};
/******************************************************************************/

View file

@ -186,38 +186,32 @@ const fromCosmeticFilter = function(details) {
switch ( filterType ) {
// Lowly generic cosmetic filters
case 0: // simple id-based
if (
exception === false &&
fargs[1] === selector.slice(1) &&
selector.charAt(0) === '#'
) {
found = prefix + selector;
}
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 === false &&
fargs[1] === selector.slice(1) &&
selector.charAt(0) === '.'
) {
found = prefix + selector;
}
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
if ( exception === false && fargs[2] === selector ) {
found = prefix + selector;
}
if ( exception ) { break; }
if ( fargs[2] !== selector ) { break; }
found = prefix + selector;
break;
// Highly generic cosmetic filters
case 4: // simple highly generic
case 5: // complex highly generic
case 7: // generic exception
if ( fargs[1] === selector ) {
found = prefix + selector;
}
if ( exception ) { break; }
if ( fargs[1] !== selector ) { break; }
found = prefix + selector;
break;
// Specific cosmetic filtering
// Generic exception
case 8:
// HTML filtering
case 64: