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
1 changed files with 8 additions and 3 deletions

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) {
const out = [];
for ( const part of parts ) {
const { data } = part;
switch ( data.type ) {
case 'AttributeSelector':
case 'AttributeSelector': {
const name = data.name.name;
const value = data.value.value || data.value.name;
out.push(
data.matcher
? `[${data.name.name}${data.matcher}"${data.value.value}"]`
: `[${data.name.name}]`
? `[${name}${data.matcher}"${value}"]`
: `[${name}]`
);
break;
}
case 'ClassSelector':
out.push(`.${data.name}`);
break;