packages feed

wai-extra 3.0.24.1 → 3.0.24.2

raw patch · 5 files changed

+22/−10 lines, 5 files

Files

ChangeLog.md view
@@ -1,3 +1,10 @@+# Changelog for wai-extra++## 3.0.24.2++* Consider quoted multipart form boundary markers [#700](https://github.com/yesodweb/wai/pull/700).+* Don't raise exceptions in `formatAsJSON` [#709](https://github.com/yesodweb/wai/pull/709)+ ## 3.0.24.1  * Fix a "file not found" exception in wai-extra [#705](https://github.com/yesodweb/wai/pull/706)
Network/Wai/Middleware/RequestLogger/JSON.hs view
@@ -11,7 +11,8 @@ import Data.IP import qualified Data.Text as T import Data.Text (Text)-import Data.Text.Encoding (decodeUtf8)+import Data.Text.Encoding (decodeUtf8With)+import Data.Text.Encoding.Error (lenientDecode) import Data.Time (NominalDiffTime) import Data.Word (Word32) import Network.HTTP.Types as H@@ -32,10 +33,10 @@         , "size"   .= responseSize         , "body"   .=           if statusCode status >= 400-            then Just . decodeUtf8 . toStrict . BB.toLazyByteString $ response+            then Just . decodeUtf8With lenientDecode . toStrict . BB.toLazyByteString $ response             else Nothing         ]-      , "time"     .= decodeUtf8 date+      , "time"     .= decodeUtf8With lenientDecode date       ]) <> "\n"  word32ToHostAddress :: Word32 -> Text@@ -47,12 +48,12 @@ requestToJSON :: NominalDiffTime -> Request -> [S8.ByteString] -> Value requestToJSON duration req reqBody =   object-    [ "method" .= decodeUtf8 (requestMethod req)-    , "path" .= decodeUtf8 (rawPathInfo req)+    [ "method" .= decodeUtf8With lenientDecode (requestMethod req)+    , "path" .= decodeUtf8With lenientDecode (rawPathInfo req)     , "queryString" .= map queryItemToJSON (queryString req)     , "durationMs" .= (readAsDouble . printf "%.2f" . rationalToDouble $ toRational duration * 1000)     , "size" .= requestBodyLengthToJSON (requestBodyLength req)-    , "body" .= decodeUtf8 (S8.concat reqBody)+    , "body" .= decodeUtf8With lenientDecode (S8.concat reqBody)     , "remoteHost" .= sockToJSON (remoteHost req)     , "httpVersion" .= httpVersionToJSON (httpVersion req)     , "headers" .= requestHeadersToJSON (requestHeaders req)@@ -78,7 +79,7 @@   object [ "can" .= i ]  queryItemToJSON :: QueryItem -> Value-queryItemToJSON (name, mValue) = toJSON (decodeUtf8 name, fmap decodeUtf8 mValue)+queryItemToJSON (name, mValue) = toJSON (decodeUtf8With lenientDecode name, fmap (decodeUtf8With lenientDecode) mValue)  requestHeadersToJSON :: RequestHeaders -> Value requestHeadersToJSON = toJSON . map hToJ where@@ -87,7 +88,7 @@   hToJ hd = headerToJSON hd  headerToJSON :: Header -> Value-headerToJSON (headerName, header) = toJSON (decodeUtf8 . original $ headerName, decodeUtf8 header)+headerToJSON (headerName, header) = toJSON (decodeUtf8With lenientDecode . original $ headerName, decodeUtf8With lenientDecode header)  portToJSON :: PortNumber -> Value portToJSON = toJSON . toInteger
Network/Wai/Parse.hs view
@@ -336,6 +336,9 @@     semicolon = 59     equals = 61     space = 32+    dq s = if S.length s > 2 && S.head s == 34 && S.last s == 34 -- quote+                then S.tail $ S.init s+                else s     goAttrs front bs         | S.null bs = front []         | otherwise =@@ -344,7 +347,7 @@     goAttr bs =         let (k, v') = S.break (== equals) bs             v = S.drop 1 v'-         in (strip k, strip v)+         in (strip k, dq $ strip v)     strip = S.dropWhile (== space) . fst . S.breakEnd (/= space)  -- | Parse the body of an HTTP request.
test/Network/Wai/ParseSpec.hs view
@@ -30,6 +30,7 @@             [ ("text/plain", "text/plain", [])             , ("text/plain; charset=UTF-8 ", "text/plain", [("charset", "UTF-8")])             , ("text/plain; charset=UTF-8 ; boundary = foo", "text/plain", [("charset", "UTF-8"), ("boundary", "foo")])+            , ("text/plain; charset=UTF-8 ; boundary = \"quoted\"", "text/plain", [("charset", "UTF-8"), ("boundary", "quoted")])             ]     it "parseHttpAccept" caseParseHttpAccept     describe "parseRequestBody" $ do
wai-extra.cabal view
@@ -1,5 +1,5 @@ Name:                wai-extra-Version:             3.0.24.1+Version:             3.0.24.2 Synopsis:            Provides some basic WAI handlers and middleware. description:   Provides basic WAI handler and middleware functionality: