Permalink
Browse files

fix nonascii filenames handling in serveDirectory

  • Loading branch information...
1 parent 3edc321 commit 21d276cd1d88cb4cb947c7de6518ec24c340c26b cvb committed Jul 5, 2012
Showing with 4 additions and 4 deletions.
  1. +2 −1 snap-core.cabal
  2. +2 −3 src/Snap/Util/FileServe.hs
View
@@ -156,7 +156,8 @@ Library
unix-compat >= 0.2 && <0.4,
unordered-containers >= 0.1.4.3 && <0.3,
vector >= 0.6 && <0.10,
- zlib-enum >= 0.2.1 && <0.3
+ zlib-enum >= 0.2.1 && <0.3,
+ utf8-string
extensions:
BangPatterns,
@@ -36,6 +36,7 @@ import Data.Attoparsec.Char8
import qualified Data.ByteString.Char8 as S
import Data.ByteString.Char8 (ByteString)
import Data.ByteString.Internal (c2w)
+import qualified Data.ByteString.UTF8 as SU
import Data.Int
import Data.List
import Data.Map (Map)
@@ -55,7 +56,6 @@ import Snap.Internal.Debug
import Snap.Internal.Parsing
import Snap.Iteratee hiding (drop)
-
------------------------------------------------------------------------------
-- | Gets a path from the 'Request' using 'rqPathInfo' and makes sure it is
-- safe to use for opening files. A path is safe if it is a relative path
@@ -65,8 +65,7 @@ getSafePath = do
req <- getRequest
let mp = urlDecode $ rqPathInfo req
- p <- maybe pass (return . S.unpack) mp
-
+ p <- maybe pass (return . SU.toString) mp
-- relative paths only!
when (not $ isRelative p) pass

0 comments on commit 21d276c

Please sign in to comment.