on master help sign in
Fix broken indexing in headerLines #274
commitd0f3c29dad0337443491b77085250379a51387be authorMichael Snoyman <michael@snoyman.com> dateFri 8 Aug 2014, 14:10 (12 years ago) parent29fe0ee
2 files changed+4−2
warp/Network/Wai/Handler/Warp/Request.hs+1−1 warp/test/RequestSpec.hs+3−1
warp/Network/Wai/Handler/Warp/Request.hs+1−1
@@ -241,6 +241,6 @@ push src (THStatus len lines prepend) bs'
241241
242242{-# INLINE checkCR #-}
243243checkCR :: ByteString -> Int -> Int
244−checkCR bs pos = if 13 == S.index bs p then p else pos -- 13 is CR
244+checkCR bs pos = if pos > 0 && 13 == S.index bs p then p else pos -- 13 is CR
245245 where
246246 !p = pos - 1
warp/test/RequestSpec.hs+3−1
@@ -84,7 +84,9 @@ spec = do
8484 it "can handle an illegal case (1)" $ do
8585 src <- mkSourceFunc ["\nStatus:", "\n 200", "\nContent-Type: text/plain", "\r\n\r\n"] >>= mkSource
8686 x <- headerLines src
87− x `shouldBe` ["Status: 200", "Content-Type: text/plain"]
87+ x `shouldBe` []
88+ y <- headerLines src
89+ y `shouldBe` ["Status: 200", "Content-Type: text/plain"]
8890
8991 where
9092 blankSafe = headerLinesList ["f", "oo\n", "bar\nbaz\n\r\n"]