Skip to content

Commit

Permalink
Correctly decode request URIs in the preview server.
Browse files Browse the repository at this point in the history
  • Loading branch information
beastaugh committed Mar 29, 2011
1 parent 98a4869 commit 29072a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions hakyll.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ library
snap-core >= 0.4,
bytestring >= 0.9,
utf8-string >= 0.3,
HTTP >= 4000,
tagsoup >= 0.12,
hopenssl >= 1.4,
unix >= 2.4,
Expand Down
3 changes: 2 additions & 1 deletion src/Hakyll/Web/Preview/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Hakyll.Web.Preview.Server
import Control.Monad.Trans (liftIO)
import Control.Applicative ((<$>))
import Codec.Binary.UTF8.String
import Network.HTTP.Base (urlDecode)
import System.FilePath ((</>))
import System.Directory (doesFileExist)

Expand Down Expand Up @@ -39,7 +40,7 @@ static directory preServe = do
let filePath = replaceAll "\\?$" (const "") -- Remove trailing ?
$ replaceAll "#[^#]*$" (const "") -- Remove #section
$ replaceAll "^/" (const "") -- Remove leading /
$ decode $ SB.unpack uri
$ urlDecode $ decode $ SB.unpack uri

-- Try to find the requested file
r <- liftIO $ findFile $ map (directory </>) $
Expand Down

0 comments on commit 29072a5

Please sign in to comment.