Skip to content
This repository

use system-filepath ro decode filename for file serve #152

Open
wants to merge 4 commits into from

1 participant

Peter Goncharov
Peter Goncharov
cvb commented July 13, 2012

Me, again, I changed utf8-string to system-filepath, and as simplest solution, I use it to convert ByteString to System.IO.FilePath in getSafePath, because you still need path as string for System.Directory.

Is this enough or I should get rid of System.FilePath functions where it is posible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
3  snap-core.cabal
@@ -151,7 +151,8 @@ Library
151 151
     unix-compat               >= 0.2     && < 0.5,
152 152
     unordered-containers      >= 0.1.4.3 && < 0.3,
153 153
     vector                    >= 0.6     && < 0.11,
154  
-    zlib-enum                 >= 0.2.1   && < 0.3
  154
+    zlib-enum                 >= 0.2.1   && < 0.3,
  155
+    system-filepath           == 0.4.*
155 156
 
156 157
   extensions:
157 158
     BangPatterns,
2  src/Snap/Internal/Parsing.hs
@@ -161,7 +161,7 @@ pQuotedString = q *> quotedText <* q
161 161
                , pure soFar' ]
162 162
 
163 163
     q      = char '\"'
164  
-    qdtext = matchAll [ isRFCText, (/= '\"'), (/= '\\') ]
  164
+    qdtext = matchAll [ (/= '\"'), (/= '\\') ]
165 165
 
166 166
 
167 167
 ------------------------------------------------------------------------------
3  src/Snap/Util/FileServe.hs
@@ -53,6 +53,7 @@ import qualified Prelude
53 53
 import           System.Directory
54 54
 import           System.FilePath
55 55
 import           System.PosixCompat.Files
  56
+import qualified Filesystem.Path.CurrentOS as FP
56 57
 ------------------------------------------------------------------------------
57 58
 import           Snap.Core
58 59
 import           Snap.Internal.Debug
@@ -69,7 +70,7 @@ getSafePath = do
69 70
     req <- getRequest
70 71
     let mp = urlDecode $ rqPathInfo req
71 72
 
72  
-    p <- maybe pass (return . S.unpack) mp
  73
+    p <- maybe pass (return . FP.encodeString . FP.decode) mp
73 74
 
74 75
     -- relative paths only!
75 76
     when (not $ isRelative p) pass
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.