mirror of https://github.com/gorhill/uBlock.git
Prepend attribute flags with space
Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/2310#issuecomment-1269001494
This commit is contained in:
parent
fd945f3358
commit
93953f9b21
|
@ -1391,7 +1391,7 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
this.nativeCssHas = instanceOptions.nativeCssHas === true;
|
this.nativeCssHas = instanceOptions.nativeCssHas === true;
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-syntax-3/#typedef-ident-token
|
// https://www.w3.org/TR/css-syntax-3/#typedef-ident-token
|
||||||
this.reValidIdentifier = /^\*|-?[A-Za-z_\xC0-\xFF\\\-]/;
|
this.reInvalidIdentifier = /^\d/;
|
||||||
}
|
}
|
||||||
|
|
||||||
compile(raw, out, compileOptions = {}) {
|
compile(raw, out, compileOptions = {}) {
|
||||||
|
@ -1579,7 +1579,7 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
switch ( data.type ) {
|
switch ( data.type ) {
|
||||||
case 'AttributeSelector': {
|
case 'AttributeSelector': {
|
||||||
const name = data.name.name;
|
const name = data.name.name;
|
||||||
if ( this.reValidIdentifier.test(name) === false ) { return; }
|
if ( this.reInvalidIdentifier.test(name) ) { return; }
|
||||||
if ( data.matcher === null ) {
|
if ( data.matcher === null ) {
|
||||||
out.push(`[${name}]`);
|
out.push(`[${name}]`);
|
||||||
break;
|
break;
|
||||||
|
@ -1591,25 +1591,25 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
value = value.replace(/"/g, '\\$&');
|
value = value.replace(/"/g, '\\$&');
|
||||||
let flags = '';
|
let flags = '';
|
||||||
if ( typeof data.flags === 'string' ) {
|
if ( typeof data.flags === 'string' ) {
|
||||||
flags = data.flags;
|
if ( /^(is?|si?)$/.test(data.flags) === false ) { return; }
|
||||||
if ( /^(i|s|is|si)$/.test(flags) === false ) { return; }
|
flags = ` ${data.flags}`;
|
||||||
}
|
}
|
||||||
out.push(`[${name}${data.matcher}"${value}"${flags}]`);
|
out.push(`[${name}${data.matcher}"${value}"${flags}]`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'ClassSelector':
|
case 'ClassSelector':
|
||||||
if ( this.reValidIdentifier.test(data.name) === false ) { return; }
|
if ( this.reInvalidIdentifier.test(data.name) ) { return; }
|
||||||
out.push(`.${data.name}`);
|
out.push(`.${data.name}`);
|
||||||
break;
|
break;
|
||||||
case 'Combinator':
|
case 'Combinator':
|
||||||
out.push(data.name === ' ' ? ' ' : ` ${data.name} `);
|
out.push(data.name === ' ' ? ' ' : ` ${data.name} `);
|
||||||
break;
|
break;
|
||||||
case 'Identifier':
|
case 'Identifier':
|
||||||
if ( this.reValidIdentifier.test(data.name) === false ) { return; }
|
if ( this.reInvalidIdentifier.test(data.name) ) { return; }
|
||||||
out.push(data.name);
|
out.push(data.name);
|
||||||
break;
|
break;
|
||||||
case 'IdSelector':
|
case 'IdSelector':
|
||||||
if ( this.reValidIdentifier.test(data.name) === false ) { return; }
|
if ( this.reInvalidIdentifier.test(data.name) ) { return; }
|
||||||
out.push(`#${data.name}`);
|
out.push(`#${data.name}`);
|
||||||
break;
|
break;
|
||||||
case 'Nth': {
|
case 'Nth': {
|
||||||
|
@ -1639,7 +1639,7 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
out.push(data.value);
|
out.push(data.value);
|
||||||
break;
|
break;
|
||||||
case 'TypeSelector':
|
case 'TypeSelector':
|
||||||
if ( this.reValidIdentifier.test(data.name) === false ) { return; }
|
if ( this.reInvalidIdentifier.test(data.name) ) { return; }
|
||||||
out.push(data.name);
|
out.push(data.name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue