mirror of https://github.com/gorhill/uBlock.git
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
|
@ -1587,15 +1587,8 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
break;
|
break;
|
||||||
case 'not': {
|
case 'not': {
|
||||||
if ( this.astHasType(args, 'Combinator', 0) === false ) { break; }
|
if ( this.astHasType(args, 'Combinator', 0) === false ) { break; }
|
||||||
const selectors = this.astSelectorsFromSelectorList(args);
|
if ( this.astIsValidSelectorList(args) !== true ) {
|
||||||
if ( Array.isArray(selectors) === false || selectors.length === 0 ) {
|
|
||||||
data.type = 'Error';
|
data.type = 'Error';
|
||||||
break;
|
|
||||||
}
|
|
||||||
for ( const selector of selectors ) {
|
|
||||||
if ( this.astIsValidSelector(selector) ) { continue; }
|
|
||||||
data.type = 'Error';
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1865,6 +1858,17 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
return true;
|
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) {
|
translateAdguardCSSInjectionFilter(suffix) {
|
||||||
const matches = /^(.*)\s*\{([^}]+)\}\s*$/.exec(suffix);
|
const matches = /^(.*)\s*\{([^}]+)\}\s*$/.exec(suffix);
|
||||||
if ( matches === null ) { return ''; }
|
if ( matches === null ) { return ''; }
|
||||||
|
@ -2071,6 +2075,7 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
const i = this.compileInteger(s, 1, 256);
|
const i = this.compileInteger(s, 1, 256);
|
||||||
if ( i !== undefined ) { return i; }
|
if ( i !== undefined ) { return i; }
|
||||||
const parts = this.astFromRaw(s, 'selectorList' );
|
const parts = this.astFromRaw(s, 'selectorList' );
|
||||||
|
if ( this.astIsValidSelectorList(parts) !== true ) { return; }
|
||||||
if ( this.astHasType(parts, 'ProceduralSelector') ) { return; }
|
if ( this.astHasType(parts, 'ProceduralSelector') ) { return; }
|
||||||
if ( this.astHasType(parts, 'ActionSelector') ) { return; }
|
if ( this.astHasType(parts, 'ActionSelector') ) { return; }
|
||||||
if ( this.astHasType(parts, 'Error') ) { return; }
|
if ( this.astHasType(parts, 'Error') ) { return; }
|
||||||
|
|
Loading…
Reference in New Issue