Commits

Bryan O'Sullivan committed 637f6cd

Tighten up the top-level json parser to be safer

Comments (0)

Files changed (1)

Data/Aeson/Parser.hs

 -- an array.
 json :: Parser Value
 json = do
-  c <- skipSpace *> anyChar
-  case c of
-    '{' -> object_
-    '[' -> array_
-    _   -> fail "root value is not an object or array"
+  c <- skipSpace *> satisfy (`B8.elem` "{[")
+  if c == '{'
+    then object_
+    else array_
 
 object_ :: Parser Value
 object_ = {-# SCC "object_" #-} do