Skip to content

Commit 0b311c8

Browse files
committed
Add standard conform JSON Escaping
Reference: RFC 8259, "7. Strings", https://tools.ietf.org/html/rfc8259#section-7
1 parent 0412dfe commit 0b311c8

File tree

1 file changed

+5
-1
lines changed
  • Cabal/src/Distribution/Utils

1 file changed

+5
-1
lines changed

Cabal/src/Distribution/Utils/Json.hs

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ surround begin end middle = mconcat [ begin , middle , end]
4343
escape :: String -> String
4444
escape ('\"':xs) = "\\\"" <> escape xs
4545
escape ('\\':xs) = "\\\\" <> escape xs
46-
escape ('\'':xs) = "\\\'" <> escape xs
46+
escape ('\b':xs) = "\\b" <> escape xs
47+
escape ('\f':xs) = "\\f" <> escape xs
48+
escape ('\n':xs) = "\\n" <> escape xs
49+
escape ('\r':xs) = "\\r" <> escape xs
50+
escape ('\t':xs) = "\\t" <> escape xs
4751
escape (x:xs) = x : escape xs
4852
escape [] = mempty
4953

0 commit comments

Comments
 (0)