Fix broken the compiling of generic cosmetic exception filters

Related issue:
- https://github.com/uBlockOrigin/uAssets/pull/9637

Regression from
- https://github.com/gorhill/uBlock/commit/c25938f
This commit is contained in:
Raymond Hill 2021-07-26 08:34:32 -04:00
parent 89064478dd
commit f392d09a13
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 7 additions and 2 deletions

View File

@ -369,7 +369,6 @@ FilterContainer.prototype.compile = function(parser, writer) {
/******************************************************************************/
FilterContainer.prototype.compileGenericSelector = function(parser, writer) {
writer.select(µb.compiledCosmeticSection + COMPILED_GENERIC_SECTION);
if ( parser.isException() ) {
this.compileGenericUnhideSelector(parser, writer);
} else {
@ -391,8 +390,11 @@ FilterContainer.prototype.compileGenericHideSelector = function(
type: 'error',
text: `Invalid generic cosmetic filter in ${who}: ${raw}`
});
return;
}
writer.select(µb.compiledCosmeticSection + COMPILED_GENERIC_SECTION);
const type = compiled.charCodeAt(0);
let key;
@ -494,6 +496,8 @@ FilterContainer.prototype.compileGenericUnhideSelector = function(
return;
}
writer.select(µb.compiledCosmeticSection + COMPILED_SPECIFIC_SECTION);
// https://github.com/chrisaljoudi/uBlock/issues/497
// All generic exception filters are stored as hostname-based filter
// whereas the hostname is the empty string (which matches all
@ -511,7 +515,6 @@ FilterContainer.prototype.compileSpecificSelector = function(
not,
writer
) {
writer.select(µb.compiledCosmeticSection + COMPILED_SPECIFIC_SECTION);
const { raw, compiled, exception } = parser.result;
if ( compiled === undefined ) {
const who = writer.properties.get('assetKey') || '?';
@ -523,6 +526,8 @@ FilterContainer.prototype.compileSpecificSelector = function(
return;
}
writer.select(µb.compiledCosmeticSection + COMPILED_SPECIFIC_SECTION);
// https://github.com/chrisaljoudi/uBlock/issues/145
let unhide = exception ? 1 : 0;
if ( not ) { unhide ^= 1; }