1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02:00

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.
This commit is contained in:
Raymond Hill 2022-08-31 13:57:39 -04:00
parent b9aa791901
commit 79451e5899
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1453,7 +1453,7 @@ Parser.prototype.SelectorCompiler = class {
} }
// Procedural selector? // Procedural selector?
const compiled = this.compileProceduralSelector(raw); const compiled = this.compileProceduralSelector(raw, asProcedural);
if ( compiled === undefined ) { return false; } if ( compiled === undefined ) { return false; }
out.compiled = out.compiled =
@ -1531,8 +1531,8 @@ Parser.prototype.SelectorCompiler = class {
return true; return true;
} }
compileProceduralSelector(raw) { compileProceduralSelector(raw, asProcedural = false) {
const compiled = this.compileProcedural(raw, true); const compiled = this.compileProcedural(raw, true, asProcedural);
if ( compiled !== undefined ) { if ( compiled !== undefined ) {
compiled.raw = this.decompileProcedural(compiled); compiled.raw = this.decompileProcedural(compiled);
} }
@ -1757,7 +1757,7 @@ Parser.prototype.SelectorCompiler = class {
return raw.join(''); return raw.join('');
} }
compileProcedural(raw, root = false) { compileProcedural(raw, root = false, asProcedural = false) {
if ( raw === '' ) { return; } if ( raw === '' ) { return; }
const tasks = []; const tasks = [];
@ -1813,6 +1813,7 @@ Parser.prototype.SelectorCompiler = class {
// "forgiving", we also need to validate that the argument itself // "forgiving", we also need to validate that the argument itself
// is also a valid CSS selector. // is also a valid CSS selector.
if ( if (
asProcedural === false &&
this.querySelectable(raw.slice(opNameBeg, i)) && this.querySelectable(raw.slice(opNameBeg, i)) &&
this.querySelectable(oparg) this.querySelectable(oparg)
) { ) {