mirror of https://github.com/gorhill/uBlock.git
Fix static filtering parser's validation of selectors/styles
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2170#issuecomment-1207921464
This commit is contained in:
parent
a69250ba82
commit
cd50f76e74
|
@ -1487,12 +1487,17 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
// selector is declarative or not.
|
// selector is declarative or not.
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/1806#issuecomment-963278382
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/1806#issuecomment-963278382
|
||||||
// Forbid multiple and unexpected CSS style declarations.
|
// Forbid multiple and unexpected CSS style declarations.
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/2170#issuecomment-1207921464
|
||||||
|
// Assigning text content to the `style` element resets the `disabled`
|
||||||
|
// state of the sheet, so we need to explicitly disable it each time we
|
||||||
|
// assign new text.
|
||||||
sheetSelectable(s) {
|
sheetSelectable(s) {
|
||||||
if ( this.reCommonSelector.test(s) ) { return true; }
|
if ( this.reCommonSelector.test(s) ) { return true; }
|
||||||
if ( this.cssValidatorElement === null ) { return true; }
|
if ( this.cssValidatorElement === null ) { return true; }
|
||||||
let valid = false;
|
let valid = false;
|
||||||
try {
|
try {
|
||||||
this.cssValidatorElement.childNodes[0].nodeValue = `_z + ${s}{color:red;} _z{color:red;}`;
|
this.cssValidatorElement.childNodes[0].nodeValue = `_z + ${s}{color:red;} _z{color:red;}`;
|
||||||
|
this.cssValidatorElement.sheet.disabled = true;
|
||||||
const rules = this.cssValidatorElement.sheet.cssRules;
|
const rules = this.cssValidatorElement.sheet.cssRules;
|
||||||
valid = rules.length === 2 &&
|
valid = rules.length === 2 &&
|
||||||
rules[0].style.cssText !== '' &&
|
rules[0].style.cssText !== '' &&
|
||||||
|
@ -1636,6 +1641,7 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
let valid = false;
|
let valid = false;
|
||||||
try {
|
try {
|
||||||
this.cssValidatorElement.childNodes[0].nodeValue = `_z{${s}} _z{color:red;}`;
|
this.cssValidatorElement.childNodes[0].nodeValue = `_z{${s}} _z{color:red;}`;
|
||||||
|
this.cssValidatorElement.sheet.disabled = true;
|
||||||
const rules = this.cssValidatorElement.sheet.cssRules;
|
const rules = this.cssValidatorElement.sheet.cssRules;
|
||||||
valid = rules.length >= 2 &&
|
valid = rules.length >= 2 &&
|
||||||
rules[0].style.cssText !== '' &&
|
rules[0].style.cssText !== '' &&
|
||||||
|
|
Loading…
Reference in New Issue