mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Better validate :upward()
argument
Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/2442#issuecomment-1371484554
This commit is contained in:
parent
3e85e51dd2
commit
7b8c096270
1 changed files with 13 additions and 8 deletions
|
@ -1587,15 +1587,8 @@ Parser.prototype.SelectorCompiler = class {
|
|||
break;
|
||||
case 'not': {
|
||||
if ( this.astHasType(args, 'Combinator', 0) === false ) { break; }
|
||||
const selectors = this.astSelectorsFromSelectorList(args);
|
||||
if ( Array.isArray(selectors) === false || selectors.length === 0 ) {
|
||||
if ( this.astIsValidSelectorList(args) !== true ) {
|
||||
data.type = 'Error';
|
||||
break;
|
||||
}
|
||||
for ( const selector of selectors ) {
|
||||
if ( this.astIsValidSelector(selector) ) { continue; }
|
||||
data.type = 'Error';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1865,6 +1858,17 @@ Parser.prototype.SelectorCompiler = class {
|
|||
return true;
|
||||
}
|
||||
|
||||
astIsValidSelectorList(args) {
|
||||
const selectors = this.astSelectorsFromSelectorList(args);
|
||||
if ( Array.isArray(selectors) === false || selectors.length === 0 ) {
|
||||
return false;
|
||||
}
|
||||
for ( const selector of selectors ) {
|
||||
if ( this.astIsValidSelector(selector) !== true ) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
translateAdguardCSSInjectionFilter(suffix) {
|
||||
const matches = /^(.*)\s*\{([^}]+)\}\s*$/.exec(suffix);
|
||||
if ( matches === null ) { return ''; }
|
||||
|
@ -2071,6 +2075,7 @@ Parser.prototype.SelectorCompiler = class {
|
|||
const i = this.compileInteger(s, 1, 256);
|
||||
if ( i !== undefined ) { return i; }
|
||||
const parts = this.astFromRaw(s, 'selectorList' );
|
||||
if ( this.astIsValidSelectorList(parts) !== true ) { return; }
|
||||
if ( this.astHasType(parts, 'ProceduralSelector') ) { return; }
|
||||
if ( this.astHasType(parts, 'ActionSelector') ) { return; }
|
||||
if ( this.astHasType(parts, 'Error') ) { return; }
|
||||
|
|
Loading…
Reference in a new issue