on master help sign in
Fixed UTF8 cleanpath handling
367442dMichael Snoyman
Network/Wai/Middleware/CleanPath.hs+2−1
@@ -10,6 +10,7 @@ import Network.Wai
10import qualified Data.ByteString.Char8 as B
10import qualified Data.ByteString.Char8 as B
11import qualified Data.ByteString.Lazy as L
11import qualified Data.ByteString.Lazy as L
12import Network.URI (unEscapeString)
12import Network.URI (unEscapeString)
13+import qualified Data.ByteString.UTF8 as BSU
13
14
14cleanPathFunc :: (B.ByteString -> Either B.ByteString [String])
15cleanPathFunc :: (B.ByteString -> Either B.ByteString [String])
15 -> B.ByteString
16 -> B.ByteString
@@ -52,7 +53,7 @@ splitPath :: B.ByteString -> Either B.ByteString [String]
52splitPath s =
53splitPath s =
53 let corrected = B.pack $ rts $ ats $ rds $ B.unpack s
54 let corrected = B.pack $ rts $ ats $ rds $ B.unpack s
54 in if corrected == s
55 in if corrected == s
55− then Right $ map (unEscapeString . B.unpack)
56+ then Right $ map (BSU.toString . B.pack . unEscapeString . B.unpack)
56 $ filter (not . B.null)
57 $ filter (not . B.null)
57 $ B.split '/' s
58 $ B.split '/' s
58 else Left corrected
59 else Left corrected
wai-extra.cabal+3−2
@@ -1,5 +1,5 @@
1Name: wai-extra
1Name: wai-extra
2−Version: 0.2.2
2+Version: 0.2.2.1
3Synopsis: Provides some basic WAI handlers and middleware.
3Synopsis: Provides some basic WAI handlers and middleware.
4Description: The goal here is to provide common features without many dependencies.
4Description: The goal here is to provide common features without many dependencies.
5License: BSD3
5License: BSD3
@@ -23,7 +23,8 @@ Library
23 time >= 1.1.4 && < 1.3,
23 time >= 1.1.4 && < 1.3,
24 sendfile >= 0.6.1 && < 0.7,
24 sendfile >= 0.6.1 && < 0.7,
25 network >= 2.2.1.5 && < 2.3,
25 network >= 2.2.1.5 && < 2.3,
26− directory >= 1.0.1 && < 1.1
26+ directory >= 1.0.1 && < 1.1,
27+ utf8-string >= 0.3.4 && < 0.4
27 Exposed-modules: Network.Wai.Handler.CGI
28 Exposed-modules: Network.Wai.Handler.CGI
28 Network.Wai.Handler.SimpleServer
29 Network.Wai.Handler.SimpleServer
29 Network.Wai.Middleware.CleanPath
30 Network.Wai.Middleware.CleanPath