mirror of https://github.com/gorhill/uBlock.git
[mv3] Fix conversion of `:xpath` procedural filters
Procedural filters with `:xpath` operator were silently rejected at conversion time because the parser was failing to evaluate the xpath expression due to the absence of a `document` object in nodejs. If `document` object is not present, the parser will assume the xpath expression is valid.
This commit is contained in:
parent
46e19e4f7f
commit
f1889b02ee
|
@ -566,6 +566,13 @@ class PSelectorRoot extends PSelector {
|
|||
}
|
||||
return [];
|
||||
}
|
||||
exec(input) {
|
||||
try {
|
||||
return super.exec(input);
|
||||
} catch (ex) {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -299,10 +299,10 @@ function addToDNR(context, list) {
|
|||
|
||||
if ( parser.isComment() ) {
|
||||
if ( line === `!#trusted on ${context.secret}` ) {
|
||||
parser.trustedSource = true;
|
||||
parser.options.trustedSource = true;
|
||||
context.trustedSource = true;
|
||||
} else if ( line === `!#trusted off ${context.secret}` ) {
|
||||
parser.trustedSource = false;
|
||||
parser.options.trustedSource = false;
|
||||
context.trustedSource = false;
|
||||
}
|
||||
continue;
|
||||
|
@ -312,6 +312,8 @@ function addToDNR(context, list) {
|
|||
if ( parser.hasError() ) {
|
||||
if ( parser.astError === sfp.AST_ERROR_OPTION_EXCLUDED ) {
|
||||
context.invalid.add(`Incompatible with DNR: ${line}`);
|
||||
} else {
|
||||
context.invalid.add(`Rejected filter: ${line}`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -4022,6 +4022,7 @@ class ExtSelectorCompiler {
|
|||
compileXpathExpression(s) {
|
||||
const r = this.unquoteString(s);
|
||||
if ( r.i !== s.length ) { return; }
|
||||
if ( globalThis.document instanceof Object === false ) { return r.s; }
|
||||
try {
|
||||
globalThis.document.createExpression(r.s, null);
|
||||
} catch (e) {
|
||||
|
|
|
@ -4571,7 +4571,7 @@ FilterContainer.prototype.dnrFromCompiled = function(op, context, ...args) {
|
|||
}
|
||||
break;
|
||||
case 'uritransform': {
|
||||
dnrAddRuleError(rule, `Unsupported uritransform=${rule.__modifierValue}`);
|
||||
dnrAddRuleError(rule, `Incompatible with DNR: uritransform=${rule.__modifierValue}`);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue