on master help sign in
make sure \r does not get through JSON escaping
commit9f92cedfb60ffd7b79ff11173e60fd18c938c668 authorEvan Czaplicki <evancz@users.noreply.github.com> dateFri 5 Jul 2019, 18:16 (7 years ago) parent5442c0b
1 file changed+2−1
compiler/src/Json/Encode.hs+2−1
compiler/src/Json/Encode.hs+2−1
@@ -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]
113113escape 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