on master help sign in
Case insensitive multipart request header lookup

Treat Content-Type and Content-Disposition header names as case insensitive when parsing the parts of multipart requests. These names were previously treated as case sensitive which causes parsing problems when attempting to parse requests that may use all lower case header names.

commitaf8be5267d577ef11f193d43fc6cb7423f206501 authorKelly McLaughlin <kelly@kelly-mclaughlin.com> dateThu 10 Mar 2016, 09:45 (11 years ago) parent7732e36
1 file changed+4−3
wai-extra/Network/Wai/Parse.hs+4−3
wai-extra/Network/Wai/Parse.hs+4−3
@@ -45,6 +45,7 @@ import Control.Monad (when, unless)
4545import Control.Monad.Trans.Resource (allocate, release, register, InternalState, runInternalState)
4646import Data.IORef
4747import Network.HTTP.Types (hContentType)
48+import Data.CaseInsensitive (mk)
4849
4950breakDiscard :: Word8 -> S.ByteString -> (S.ByteString, S.ByteString)
5051breakDiscard w s =
@@ -300,11 +301,11 @@ parsePieces sink bound rbody add =
300301 (wasFound, ()) <- sinkTillBound bound iter seed src
301302 when wasFound (loop src)
302303 where
303− contDisp = S8.pack "Content-Disposition"
304− contType = S8.pack "Content-Type"
304+ contDisp = mk $ S8.pack "Content-Disposition"
305+ contType = mk $ S8.pack "Content-Type"
305306 parsePair s =
306307 let (x, y) = breakDiscard 58 s -- colon
307− in (x, S.dropWhile (== 32) y) -- space
308+ in (mk $ x, S.dropWhile (== 32) y) -- space
308309
309310data Bound = FoundBound S.ByteString S.ByteString
310311 | NoBound