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