Skip to content

Commit 9f92ced

Browse files
committed
make sure \r does not get through JSON escaping
1 parent 5442c0b commit 9f92ced

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/src/Json/Encode.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ chars chrs =
109109
String (B.char7 '"' <> B.stringUtf8 (escape chrs) <> B.char7 '"')
110110

111111

112-
escape :: [Char] -> [Char] -- TODO is this correct?
112+
escape :: [Char] -> [Char]
113113
escape chrs =
114114
case chrs of
115115
[] ->
116116
[]
117117

118118
c:cs
119+
| c == '\r' -> '\\' : 'r' : escape cs
119120
| c == '\n' -> '\\' : 'n' : escape cs
120121
| c == '\"' -> '\\' : '"' : escape cs
121122
| c == '\'' -> '\\' : '\'' : escape cs

0 commit comments

Comments
 (0)