File tree Expand file tree Collapse file tree 6 files changed +35
-3
lines changed Expand file tree Collapse file tree 6 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,7 @@ test-suite aeson-tests
176176 Regression.Issue571
177177 Regression.Issue687
178178 Regression.Issue967
179+ Regression.Issue1138
179180 RFC8785
180181 SerializationFormatSpec
181182 Types
Original file line number Diff line number Diff line change @@ -153,7 +153,9 @@ scanStringLiteral ok err bs0 = go 0 bs0 where
153153 Right t -> ok t (BS. drop (n + 1 ) bs0)
154154 Left e -> err (show e)
155155 Just (92 , bs') -> goSlash (n + 1 ) bs'
156- Just (_, bs') -> goEsc (n + 1 ) bs'
156+ Just (w8, bs')
157+ | w8 < 0x20 -> errCC
158+ | otherwise -> goEsc (n + 1 ) bs'
157159
158160 goSlash :: Int -> ByteString -> r
159161 goSlash ! n ! bs = case BS. uncons bs of
Original file line number Diff line number Diff line change @@ -159,7 +159,9 @@ scanStringLiteral ok err bs0 = go 0 bs0 where
159159 Right t -> ok t (lbsDrop (n + 1 ) bs0)
160160 Left e -> err (show e)
161161 Just (92 , bs') -> goSlash (n + 1 ) bs'
162- Just (_, bs') -> goEsc (n + 1 ) bs'
162+ Just (w8, bs')
163+ | w8 < 0x20 -> errCC
164+ | otherwise -> goEsc (n + 1 ) bs'
163165
164166 goSlash :: Int -> ByteString -> r
165167 goSlash ! n ! bs = case LBS. uncons bs of
Original file line number Diff line number Diff line change @@ -163,7 +163,9 @@ scanStringLiteral ok err bs0 = go 0 bs0 where
163163 Right t -> ok t (unsafeDropPoints (n + 1 ) bs0)
164164 Left e -> err (show e)
165165 Just (92 , bs') -> goSlash (n + 1 ) bs'
166- Just (_, bs') -> goEsc (n + 1 ) bs'
166+ Just (w8, bs')
167+ | w8 < 0x20 -> errCC
168+ | otherwise -> goEsc (n + 1 ) bs'
167169
168170 goSlash :: Int -> Text -> r
169171 goSlash ! n ! bs = case unconsPoint bs of
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE OverloadedStrings #-}
2+ module Regression.Issue1138 (issue1138 ) where
3+
4+ import Test.Tasty (TestTree , testGroup )
5+ import Test.Tasty.HUnit (testCase , assertFailure )
6+
7+ import Data.Aeson
8+
9+ assertDecodeFailure :: Either String Value -> IO ()
10+ assertDecodeFailure (Right v) = assertFailure $ " Unexpected success: " ++ show v
11+ assertDecodeFailure (Left _) = return ()
12+
13+ issue1138 :: TestTree
14+ issue1138 = testGroup " Issue #1138" $ map (testCase " -" )
15+ [ assertDecodeFailure $ eitherDecode " \"\t\" "
16+ , assertDecodeFailure $ eitherDecode " \"\\\\\t\" "
17+
18+ , assertDecodeFailure $ eitherDecodeStrict " \"\t\" "
19+ , assertDecodeFailure $ eitherDecodeStrict " \"\\\\\t\" "
20+
21+ , assertDecodeFailure $ eitherDecodeStrictText " \"\t\" "
22+ , assertDecodeFailure $ eitherDecodeStrictText " \"\\\\\t\" "
23+ ]
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ import Regression.Issue351
6464import Regression.Issue571
6565import Regression.Issue687
6666import Regression.Issue967
67+ import Regression.Issue1138
6768import UnitTests.OmitNothingFieldsNote
6869import UnitTests.FromJSONKey
6970import UnitTests.Hashable
@@ -568,6 +569,7 @@ tests = testGroup "unit" [
568569 , issue571
569570 , issue687
570571 , issue967
572+ , issue1138
571573 , keyMapInsertWithTests
572574 , omitNothingFieldsNoteTests
573575 , noThunksTests
You can’t perform that action at this time.
0 commit comments