Skip to content

Commit 9853926

Browse files
committed
Escape '"' and "\" in a string with literal
1 parent 10a3558 commit 9853926

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

parse-css.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,13 +780,12 @@ function escapeString(string) {
780780
// Escapes the contents (between the quotes) of a string
781781
return Array.from(String(string), e=>{
782782
const code = e.codePointAt(0);
783-
if(between(code, 0x0, 0x1f)
784-
|| code == 0x7f
785-
|| code == 0x22
786-
|| code == 0x5c
787-
) {
783+
if(between(code, 0x0, 0x1f) || code === 0x7f) {
788784
return "\\" + code.toString(16) + " ";
789785
}
786+
if(code === 0x22 || code === 0x5c) {
787+
return "\\" + String.fromCodePoint(code);
788+
}
790789
return e;
791790
}).join("");
792791
}

0 commit comments

Comments
 (0)