Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion snap-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ Library
unix-compat >= 0.2 && < 0.5,
unordered-containers >= 0.1.4.3 && < 0.3,
vector >= 0.6 && < 0.11,
zlib-enum >= 0.2.1 && < 0.3
zlib-enum >= 0.2.1 && < 0.3,
system-filepath == 0.4.*

extensions:
BangPatterns,
Expand Down
2 changes: 1 addition & 1 deletion src/Snap/Internal/Parsing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pQuotedString = q *> quotedText <* q
, pure soFar' ]

q = char '\"'
qdtext = matchAll [ isRFCText, (/= '\"'), (/= '\\') ]
qdtext = matchAll [ (/= '\"'), (/= '\\') ]


------------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/Snap/Util/FileServe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import qualified Prelude
import System.Directory
import System.FilePath
import System.PosixCompat.Files
import qualified Filesystem.Path.CurrentOS as FP
------------------------------------------------------------------------------
import Snap.Core
import Snap.Internal.Debug
Expand All @@ -69,7 +70,7 @@ getSafePath = do
req <- getRequest
let mp = urlDecode $ rqPathInfo req

p <- maybe pass (return . S.unpack) mp
p <- maybe pass (return . FP.encodeString . FP.decode) mp

-- relative paths only!
when (not $ isRelative p) pass
Expand Down