Permalink
Browse files

Tighten up the top-level json parser to be safer

  • Loading branch information...
1 parent c42a644 commit abbe11259af6569cd8346b38ce964b01cd17b657 @bos committed May 24, 2011
Showing with 4 additions and 5 deletions.
  1. +4 −5 Data/Aeson/Parser.hs
View
9 Data/Aeson/Parser.hs
@@ -40,11 +40,10 @@ import qualified Data.ByteString.Unsafe as B
-- 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

0 comments on commit abbe112

Please sign in to comment.