Skip to content
Permalink
Browse files

Narrow the set of whitespace characters considered valid

This is required by RFC 7159. Once again spotted by JSONTestSuite.
  • Loading branch information...
bos committed Oct 29, 2016
1 parent 9cbf982 commit 8ef622c2ad8d4a109884e17c2792238a2a320e44
Showing with 7 additions and 2 deletions.
  1. +7 −1 Data/Aeson/Parser/Internal.hs
  2. +0 −1 tests/UnitTests.hs
@@ -39,7 +39,7 @@ import Prelude.Compat
import Control.Applicative ((<|>))
import Control.Monad (void, when)
import Data.Aeson.Types.Internal (IResult(..), JSONPath, Result(..), Value(..))
import Data.Attoparsec.ByteString.Char8 (Parser, char, decimal, endOfInput, isDigit_w8, signed, skipSpace, string)
import Data.Attoparsec.ByteString.Char8 (Parser, char, decimal, endOfInput, isDigit_w8, signed, string)
import Data.Scientific (Scientific)
import Data.Text (Text)
import Data.Vector as Vector (Vector, empty, fromListN, reverse)
@@ -295,6 +295,12 @@ jsonEOF = json <* skipSpace <* endOfInput
jsonEOF' :: Parser Value
jsonEOF' = json' <* skipSpace <* endOfInput

-- | The only valid whitespace in a JSON document is space, newline,
-- carriage return, and tab.
skipSpace :: Parser ()
skipSpace = A.skipWhile $ \w -> w == 0x20 || w == 0x0a || w == 0x0d || w == 0x09
{-# INLINE skipSpace #-}

------------------ Copy-pasted and adapted from attoparsec ------------------

-- A strict pair
@@ -670,7 +670,6 @@ _blacklist = HashSet.fromList [
, "n_string_unescaped_crtl_char.json"
, "n_string_unescaped_newline.json"
, "n_string_unescaped_tab.json"
, "n_structure_whitespace_formfeed.json"
, "string_1_escaped_invalid_codepoint.json"
, "string_1_invalid_codepoint.json"
, "string_1_invalid_codepoints.json"

0 comments on commit 8ef622c

Please sign in to comment.
You can’t perform that action at this time.