on master help sign in
Merge pull request #132 from tsuraan/master

Fix for https://github.com/yesodweb/wai/issues/131

commit3e5c3787982abd8a6e8058dc1ada31d80ed15c3f authorMichael Snoyman <michael@snoyman.com> dateSun 6 Jan 2013, 09:42 (14 years ago) parent86d78def0bf7d6
2 files changed+8−1
warp/Network/Wai/Handler/Warp/Request.hs+5−1 warp/test/RequestSpec.hs+3
warp/Network/Wai/Handler/Warp/Request.hs+5−1
@@ -160,7 +160,11 @@ push (THStatus len lines prepend) bs
160160 -- if so, see if the second of those is a horizontal space
161161 if bsLen > nl + 1 then
162162 let c = S.index bs (nl + 1)
163− in Just (nl, c == 32 || c == 9)
163+ b = case nl of
164+ 0 -> True
165+ 1 -> S.index bs 0 == 13
166+ _ -> False
167+ in Just (nl, (not b) && (c == 32 || c == 9))
164168 else
165169 Just (nl, False)
166170
warp/test/RequestSpec.hs+3
@@ -15,12 +15,15 @@ spec :: Spec
1515spec = describe "takeHeaders" $ do
1616 it "takes until blank" $
1717 blankSafe >>= (`shouldBe` ["foo", "bar", "baz"])
18+ it "ignored leading whitespace in bodies" $
19+ whiteSafe >>= (`shouldBe` ["foo", "bar", "baz"])
1820 it "throws OverLargeHeader when too many" $
1921 tooMany `shouldThrow` overLargeHeader
2022 it "throws OverLargeHeader when too large" $
2123 tooLarge `shouldThrow` overLargeHeader
2224 where
2325 blankSafe = runResourceT $ (sourceList ["f", "oo\n", "bar\nbaz\n\r\n"]) $$ takeHeaders
26+ whiteSafe = runResourceT $ (sourceList ["foo\r\nbar\r\nbaz\r\n\r\n hi there"]) $$ takeHeaders
2427 tooMany = runResourceT $ (sourceList $ repeat "f\n") $$ takeHeaders
2528 tooLarge = runResourceT $ (sourceList $ repeat "f") $$ takeHeaders
2629