From 79451e5899a83682548147b08e7e51004962650c Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 31 Aug 2022 13:57:39 -0400 Subject: [PATCH] Force prodecural cosmetic filtering when explicitly stated Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2228 Using `#?#` (instead of `##` for a procedural cosmetic filter will prevent uBO from trying to convert the filter into a declarative one. --- src/js/static-filtering-parser.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index 27d95159a..b21d24103 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -1453,7 +1453,7 @@ Parser.prototype.SelectorCompiler = class { } // Procedural selector? - const compiled = this.compileProceduralSelector(raw); + const compiled = this.compileProceduralSelector(raw, asProcedural); if ( compiled === undefined ) { return false; } out.compiled = @@ -1531,8 +1531,8 @@ Parser.prototype.SelectorCompiler = class { return true; } - compileProceduralSelector(raw) { - const compiled = this.compileProcedural(raw, true); + compileProceduralSelector(raw, asProcedural = false) { + const compiled = this.compileProcedural(raw, true, asProcedural); if ( compiled !== undefined ) { compiled.raw = this.decompileProcedural(compiled); } @@ -1757,7 +1757,7 @@ Parser.prototype.SelectorCompiler = class { return raw.join(''); } - compileProcedural(raw, root = false) { + compileProcedural(raw, root = false, asProcedural = false) { if ( raw === '' ) { return; } const tasks = []; @@ -1813,6 +1813,7 @@ Parser.prototype.SelectorCompiler = class { // "forgiving", we also need to validate that the argument itself // is also a valid CSS selector. if ( + asProcedural === false && this.querySelectable(raw.slice(opNameBeg, i)) && this.querySelectable(oparg) ) {