From da86e231d49f681f0d2867e42b6baabe15beac27 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 29 Apr 2025 11:27:11 -0400 Subject: [PATCH] Handle CRLF in strings --- packages/tailwindcss/src/css-parser.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/tailwindcss/src/css-parser.ts b/packages/tailwindcss/src/css-parser.ts index e98f53820..e458ec124 100644 --- a/packages/tailwindcss/src/css-parser.ts +++ b/packages/tailwindcss/src/css-parser.ts @@ -159,7 +159,11 @@ export function parse(input: string) { // ^ Missing " // } // ``` - else if (peekChar === SEMICOLON && input.charCodeAt(j + 1) === LINE_BREAK) { + else if ( + peekChar === SEMICOLON && + (input.charCodeAt(j + 1) === LINE_BREAK || + (input.charCodeAt(j + 1) === CARRIAGE_RETURN && input.charCodeAt(j + 2) === LINE_BREAK)) + ) { throw new Error( `Unterminated string: ${input.slice(start, j + 1) + String.fromCharCode(currentChar)}`, ) @@ -175,7 +179,10 @@ export function parse(input: string) { // ^ Missing " // } // ``` - else if (peekChar === LINE_BREAK) { + else if ( + peekChar === LINE_BREAK || + (peekChar === CARRIAGE_RETURN && input.charCodeAt(j + 1) === LINE_BREAK) + ) { throw new Error( `Unterminated string: ${input.slice(start, j) + String.fromCharCode(currentChar)}`, )