summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Simon Van Casteren <simonvancasteren@localhost.localdomain>2019-12-13 19:35:58 +0100
committerGravatar Simon Van Casteren <simonvancasteren@localhost.localdomain>2019-12-13 19:35:58 +0100
commit1b07e7b1e1b8a81197e98a71baf9c51579f48a3f (patch)
tree230b89560ad8b54eac89b40e00771ec739f687b2 /src
parente74d203806efea612ef2ab33da1e561c077d6c16 (diff)
Fixed JSON parsing: newline escaping
Diffstat (limited to 'src')
-rw-r--r--src/json.sml16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/json.sml b/src/json.sml
index 4f604cc4..81d7b8b4 100644
--- a/src/json.sml
+++ b/src/json.sml
@@ -121,12 +121,18 @@ struct
if peek () = #"\\" andalso (String.sub (!inputData, 1)) = #"\""
then (consume "\\\""; pickChars (s ^ "\""))
else
- if peek () = #"\\" andalso (String.sub (!inputData, 1)) = #"n"
- then (consume "\\n"; pickChars (s ^ "\n"))
+ if peek () = #"\\" andalso String.sub (!inputData, 1) = #"\\" andalso String.sub (!inputData, 2) = #"n"
+ then (consume "\\\\n"; pickChars (s ^ "\\n"))
else
- if peek () = #"\\" andalso (String.sub (!inputData, 1)) = #"r"
- then (consume "\\r"; pickChars (s ^ "\r"))
- else pickChars (s ^ String.str (take ()))
+ if peek () = #"\\" andalso (String.sub (!inputData, 1)) = #"n"
+ then (consume "\\n"; pickChars (s ^ "\n"))
+ else
+ if peek () = #"\\" andalso String.sub (!inputData, 1) = #"\\" andalso String.sub (!inputData, 2) = #"r"
+ then (consume "\\\\r"; pickChars (s ^ "\\r"))
+ else
+ if peek () = #"\\" andalso (String.sub (!inputData, 1)) = #"r"
+ then (consume "\\r"; pickChars (s ^ "\r"))
+ else pickChars (s ^ String.str (take ()))
in
pickChars ""
end