Skip to content

Commit f01eabb

Browse files
fix(css): read a CRLF after an astral escape as its one terminator
1 parent 9891111 commit f01eabb

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎lib/css/syntax-printer.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,8 +1995,10 @@ const _unescapeAstral = (raw) => {
19951995
i = end === i + 1 ? i + 1 : end - 1;
19961996
continue;
19971997
}
1998-
// The one whitespace after a hex escape ends it and is no character.
1999-
if (isWhitespace(raw.charCodeAt(end))) end++;
1998+
// The one whitespace after a hex escape ends it and is no character, a
1999+
// CRLF pair being that one (CSS Syntax 3 §4.3.7).
2000+
const after = raw.charCodeAt(end);
2001+
if (isWhitespace(after)) end = consumeExtraNewline(after, raw, end + 1);
20002002
out += raw.slice(from, i) + String.fromCodePoint(code);
20012003
from = end;
20022004
i = end - 1;

‎test/unitCases/CssSyntax.unittest.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13465,6 +13465,8 @@ describe("CssSyntax minify — `declareCharset`", () => {
1346513465
'@charset "UTF-8";a{content:"\u{1F600}a\u{1F600} b"}'
1346613466
],
1346713467
['a{content:"\\01F600"}', '@charset "UTF-8";a{content:"\u{1F600}"}'],
13468+
// A CRLF pair is that one whitespace, so no newline is left in the string.
13469+
['a{content:"\\1F600\r\nx"}', '@charset "UTF-8";a{content:"\u{1F600}x"}'],
1346813470
// An escape in the BMP beside it keeps its spelling.
1346913471
[
1347013472
'a{content:"\\e900\\1F600"}',

0 commit comments

Comments
 (0)