From f392d09a13640cd41fee091e6329421c36eaf63f Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 26 Jul 2021 08:34:32 -0400 Subject: [PATCH] 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 --- src/js/cosmetic-filtering.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index f0d045475..b3a4f05dd 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -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; }