Skip to content

Commit

Permalink
Fix escaping of \u0000 and a standalone surrogate
Browse files Browse the repository at this point in the history
  • Loading branch information
danny0838 committed Mar 31, 2024
1 parent c6a916e commit 0d0fee3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parse-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function tokenize(str) {
}
if(whitespace(next())) consume();
var value = parseInt(digits.map(function(x){return String.fromCharCode(x);}).join(''), 16);
if( value > maximumallowedcodepoint ) value = 0xfffd;
if (value === 0x0 || between(value, 0xd800, 0xdfff) || value > maximumallowedcodepoint ) value = 0xfffd;
return value;
} else if(eof()) {
return 0xfffd;
Expand Down
9 changes: 9 additions & 0 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,15 @@ var TESTS = [
"value": "\uFFFD"
},
]
}, {
parser: '',
css: `\\20000 \\0 \\D800 \\DFFF \\110000 `,
expected: [
{
"type": "IDENT",
"value": "\u{20000}\uFFFD\uFFFD\uFFFD\uFFFD"
},
]
}
];

Expand Down

0 comments on commit 0d0fee3

Please sign in to comment.