Skip to content

Commit

Permalink
Force prodecural cosmetic filtering when explicitly stated
Browse files Browse the repository at this point in the history
Related issue:
- uBlockOrigin/uBlock-issues#2228

Using `#?#` (instead of `##` for a procedural cosmetic filter will
prevent uBO from trying to convert the filter into a declarative
one.
  • Loading branch information
gorhill committed Aug 31, 2022
1 parent b9aa791 commit 79451e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/js/static-filtering-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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)
) {
Expand Down

0 comments on commit 79451e5

Please sign in to comment.