on master help sign in
Consider quoted multipart form boundary markers
commit22178a36111f9ea23cc174396067955e611443e0 authorChristian Marie <christian@daisee.com> dateThu 26 Jul 2018, 14:19 (8 years ago) parentf901afb
2 files changed+5−1
wai-extra/Network/Wai/Parse.hs+4−1 wai-extra/test/Network/Wai/ParseSpec.hs+1
wai-extra/Network/Wai/Parse.hs+4−1
@@ -336,6 +336,9 @@ parseContentType a = do
336336 semicolon = 59
337337 equals = 61
338338 space = 32
339+ dq s = if S.length s > 2 && S.head s == 34 && S.last s == 34 -- quote
340+ then S.tail $ S.init s
341+ else s
339342 goAttrs front bs
340343 | S.null bs = front []
341344 | otherwise =
@@ -344,7 +347,7 @@ parseContentType a = do
344347 goAttr bs =
345348 let (k, v') = S.break (== equals) bs
346349 v = S.drop 1 v'
347− in (strip k, strip v)
350+ in (strip k, dq $ strip v)
348351 strip = S.dropWhile (== space) . fst . S.breakEnd (/= space)
349352
350353-- | Parse the body of an HTTP request.
wai-extra/test/Network/Wai/ParseSpec.hs+1
@@ -30,6 +30,7 @@ spec = do
3030 [ ("text/plain", "text/plain", [])
3131 , ("text/plain; charset=UTF-8 ", "text/plain", [("charset", "UTF-8")])
3232 , ("text/plain; charset=UTF-8 ; boundary = foo", "text/plain", [("charset", "UTF-8"), ("boundary", "foo")])
33+ , ("text/plain; charset=UTF-8 ; boundary = \"quoted\"", "text/plain", [("charset", "UTF-8"), ("boundary", "quoted")])
3334 ]
3435 it "parseHttpAccept" caseParseHttpAccept
3536 describe "parseRequestBody" $ do