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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
exec(input) {
|
||||||
|
try {
|
||||||
|
return super.exec(input);
|
||||||
|
} catch (ex) {
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
@ -299,10 +299,10 @@ function addToDNR(context, list) {
|
||||||
|
|
||||||
if ( parser.isComment() ) {
|
if ( parser.isComment() ) {
|
||||||
if ( line === `!#trusted on ${context.secret}` ) {
|
if ( line === `!#trusted on ${context.secret}` ) {
|
||||||
parser.trustedSource = true;
|
parser.options.trustedSource = true;
|
||||||
context.trustedSource = true;
|
context.trustedSource = true;
|
||||||
} else if ( line === `!#trusted off ${context.secret}` ) {
|
} else if ( line === `!#trusted off ${context.secret}` ) {
|
||||||
parser.trustedSource = false;
|
parser.options.trustedSource = false;
|
||||||
context.trustedSource = false;
|
context.trustedSource = false;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -312,6 +312,8 @@ function addToDNR(context, list) {
|
||||||
if ( parser.hasError() ) {
|
if ( parser.hasError() ) {
|
||||||
if ( parser.astError === sfp.AST_ERROR_OPTION_EXCLUDED ) {
|
if ( parser.astError === sfp.AST_ERROR_OPTION_EXCLUDED ) {
|
||||||
context.invalid.add(`Incompatible with DNR: ${line}`);
|
context.invalid.add(`Incompatible with DNR: ${line}`);
|
||||||
|
} else {
|
||||||
|
context.invalid.add(`Rejected filter: ${line}`);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4022,6 +4022,7 @@ class ExtSelectorCompiler {
|
||||||
compileXpathExpression(s) {
|
compileXpathExpression(s) {
|
||||||
const r = this.unquoteString(s);
|
const r = this.unquoteString(s);
|
||||||
if ( r.i !== s.length ) { return; }
|
if ( r.i !== s.length ) { return; }
|
||||||
|
if ( globalThis.document instanceof Object === false ) { return r.s; }
|
||||||
try {
|
try {
|
||||||
globalThis.document.createExpression(r.s, null);
|
globalThis.document.createExpression(r.s, null);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -4571,7 +4571,7 @@ FilterContainer.prototype.dnrFromCompiled = function(op, context, ...args) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'uritransform': {
|
case 'uritransform': {
|
||||||
dnrAddRuleError(rule, `Unsupported uritransform=${rule.__modifierValue}`);
|
dnrAddRuleError(rule, `Incompatible with DNR: uritransform=${rule.__modifierValue}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue