mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-25 11:52:51 +01:00
Validate result type of XPath expressions
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3403 To ensure XPath expressions not meant to return a nodeset are discarded at compile time.
This commit is contained in:
parent
447476ab9b
commit
c746633693
@ -4116,9 +4116,11 @@ class ExtSelectorCompiler {
|
||||
compileXpathExpression(s) {
|
||||
const r = this.unquoteString(s);
|
||||
if ( r.i !== s.length ) { return; }
|
||||
if ( globalThis.document instanceof Object === false ) { return r.s; }
|
||||
const doc = globalThis.document;
|
||||
if ( doc instanceof Object === false ) { return r.s; }
|
||||
try {
|
||||
globalThis.document.createExpression(r.s, null);
|
||||
const expr = doc.createExpression(r.s, null);
|
||||
expr.evaluate(doc, XPathResult.ANY_UNORDERED_NODE_TYPE);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user