on master help sign in
Merge pull request #700 from DaiseeLabs/multipart-boundary

Consider quoted multipart form boundary markers

commit733e35a6c906c5d7cc1666366522f464af13556f authorMichael Snoyman <michael@snoyman.com> dateSun 19 Aug 2018, 05:24 (8 years ago) parentf901afb566e9fd
4 files changed+10−2
wai-extra/ChangeLog.md+4 wai-extra/Network/Wai/Parse.hs+4−1 wai-extra/test/Network/Wai/ParseSpec.hs+1 wai-extra/wai-extra.cabal+1−1
wai-extra/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.0.24.2
2+
3+* Consider quoted multipart form boundary markers [#700](https://github.com/yesodweb/wai/pull/700).
4+
15## 3.0.24.1
26
37* Fix a "file not found" exception in wai-extra [#705](https://github.com/yesodweb/wai/pull/706)
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
wai-extra/wai-extra.cabal+1−1
@@ -1,5 +1,5 @@
11Name: wai-extra
2−Version: 3.0.24.1
2+Version: 3.0.24.2
33Synopsis: Provides some basic WAI handlers and middleware.
44description:
55 Provides basic WAI handler and middleware functionality: