Skip to content

Commit

Permalink
Redirect non-existing operators to a void operator
Browse files Browse the repository at this point in the history
Related issue:
- uBlockOrigin/uBlock-issues#2292

This will prevent unexpected oversezealous blocking if ever
this happens again. The internal void operator will ensure
no blocking takes place and issue a note about non-existing
operator to the dev tools console.
  • Loading branch information
gorhill committed Sep 26, 2022
1 parent a78bb0f commit 990ad75
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/js/contentscript-extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class PSelectorTask {
}
}

class PSelectorVoidTask extends PSelectorTask {
constructor(task) {
super();
console.info(`uBO: :${task[0]}() operator does not exist`);
}
transpose() {
}
}

class PSelectorHasTextTask extends PSelectorTask {
constructor(task) {
Expand Down Expand Up @@ -377,8 +385,7 @@ class PSelector {
const tasks = [];
if ( Array.isArray(o.tasks) === false ) { return; }
for ( const task of o.tasks ) {
const ctor = this.operatorToTaskMap.get(task[0]);
if ( ctor === undefined ) { return; }
const ctor = this.operatorToTaskMap.get(task[0]) || PSelectorVoidTask;
tasks.push(new ctor(task));
}
// Initialize only after all tasks have been successfully instantiated
Expand Down

0 comments on commit 990ad75

Please sign in to comment.