X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FStaticFile.hs;h=7ceb787d5a9355a040559cc867630efb090aa0ae;hp=5b0ce579ed66e41bc0c1e1d926588743e05468ae;hb=195fd2318fb0ad21c2fd60f61e7df72a8f25d12c;hpb=f62b6f07bbf1eefcf552163d8f7daa6e0862ed5d diff --git a/Network/HTTP/Lucu/StaticFile.hs b/Network/HTTP/Lucu/StaticFile.hs index 5b0ce57..7ceb787 100644 --- a/Network/HTTP/Lucu/StaticFile.hs +++ b/Network/HTTP/Lucu/StaticFile.hs @@ -23,6 +23,7 @@ import Network.HTTP.Lucu.Resource import Network.HTTP.Lucu.Resource.Tree import Network.HTTP.Lucu.Response import Network.HTTP.Lucu.Utils +import System.FilePath.Posix import System.Posix.Files @@ -134,16 +135,15 @@ staticDir path -- 'Network.HTTP.Lucu.Resource.Tree.ResTree', you had better use -- 'staticDir' instead of this. handleStaticDir :: FilePath -> Resource () -handleStaticDir basePath - = basePath `seq` - do extraPath <- getPathInfo +handleStaticDir !basePath + = do extraPath <- getPathInfo securityCheck extraPath - let path = basePath ++ "/" ++ joinWith "/" extraPath + let path = basePath joinPath extraPath handleStaticFile path where securityCheck :: Monad m => [String] -> m () - securityCheck pathElems - = pathElems `seq` - when (any (== "..") pathElems) $ fail ("security error: " + securityCheck !pathElems + = when (any (== "..") pathElems) $ fail ("security error: " ++ joinWith "/" pathElems) +-- TODO: implement directory listing.