1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-23 10:52:43 +01:00

Fix serializing of unquoted attribute values

Related commit:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2300
This commit is contained in:
Raymond Hill 2022-09-28 08:34:39 -04:00
parent a47484bc33
commit 7379bafb23
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1570,18 +1570,23 @@ Parser.prototype.SelectorCompiler = class {
} }
} }
// https://github.com/uBlockOrigin/uBlock-issues/issues/2300
// Unquoted atrtibute values are parsed as Identifier instead of String.
astSerialize(parts) { astSerialize(parts) {
const out = []; const out = [];
for ( const part of parts ) { for ( const part of parts ) {
const { data } = part; const { data } = part;
switch ( data.type ) { switch ( data.type ) {
case 'AttributeSelector': case 'AttributeSelector': {
const name = data.name.name;
const value = data.value.value || data.value.name;
out.push( out.push(
data.matcher data.matcher
? `[${data.name.name}${data.matcher}"${data.value.value}"]` ? `[${name}${data.matcher}"${value}"]`
: `[${data.name.name}]` : `[${name}]`
); );
break; break;
}
case 'ClassSelector': case 'ClassSelector':
out.push(`.${data.name}`); out.push(`.${data.name}`);
break; break;