filestore 0.4.0.1 → 0.4.0.2
raw patch · 2 files changed
+16/−14 lines, 2 filesdep ~directorydep ~filepathdep ~process
Dependency ranges changed: directory, filepath, process
Files
- Data/FileStore/Utils.hs +12/−10
- filestore.cabal +4/−4
Data/FileStore/Utils.hs view
@@ -14,7 +14,6 @@ runShellCommand , mergeContents , hashsMatch- , isInsideDir , escapeRegexSpecialChars , parseMatchLine , splitEmailAuthor@@ -33,7 +32,7 @@ import Data.List (intersect, nub, isPrefixOf, isInfixOf) import Data.List.Split (splitWhen) import Data.Maybe (isJust)-import System.Directory (canonicalizePath, doesFileExist, getTemporaryDirectory, removeFile, findExecutable, createDirectoryIfMissing, getDirectoryContents)+import System.Directory (doesFileExist, getTemporaryDirectory, removeFile, findExecutable, createDirectoryIfMissing, getDirectoryContents) import System.Exit (ExitCode(..)) import System.FilePath ((</>), takeDirectory) import System.IO (openTempFile, hClose)@@ -120,11 +119,12 @@ -- | Inquire of a certain directory whether another file lies within its ambit. -- This is basically asking whether the file is 'above' the directory in the filesystems's -- directory tree. Useful for checking the legality of a filename.-isInsideDir :: FilePath -> FilePath -> IO Bool-isInsideDir name dir = do- gitDirPathCanon <- canonicalizePath dir- filenameCanon <- canonicalizePath name- return (gitDirPathCanon `isPrefixOf` filenameCanon)+-- Note: due to changes in canonicalizePath in ghc 7, we no longer have+-- a reliable way to do this; so isInsideDir is False whenever either+-- the file or the directory contains "..".+isInsideDir :: FilePath -> FilePath -> Bool+isInsideDir name dir = dir `isPrefixOf` name+ && not (".." `isInfixOf` dir) && not (".." `isInfixOf` name) -- | A parser function. This is intended for use on strings which are output by grep programs -- or programs which mimic the standard grep output - which uses colons as delimiters and has@@ -186,9 +186,11 @@ -> IO b withSanityCheck repo excludes name action = do let filename = repo </> encodeString name- insideRepo <- filename `isInsideDir` repo- insideExcludes <- liftM or $ mapM (filename `isInsideDir`) $ map (repo </>) excludes- when (insideExcludes || not insideRepo) $ throwIO IllegalResourceName+ let insideRepo = filename `isInsideDir` repo+ let insideExcludes = or $ map (filename `isInsideDir`)+ $ map (repo </>) excludes+ when (insideExcludes || not insideRepo)+ $ throwIO IllegalResourceName createDirectoryIfMissing True $ takeDirectory filename action
filestore.cabal view
@@ -1,5 +1,5 @@ Name: filestore-Version: 0.4.0.1+Version: 0.4.0.2 Cabal-version: >= 1.2 Build-type: Custom Tested-with: GHC==6.10.1@@ -34,10 +34,10 @@ Build-depends: base >= 4 && < 5, bytestring >= 0.9 && < 1.0, utf8-string >= 0.3 && < 0.4,- filepath >= 1.1 && < 1.2,- directory >= 1.0 && < 1.1,+ filepath >= 1.1 && < 1.3,+ directory >= 1.0 && < 1.2, parsec >= 2 && < 3.2,- process >= 1.0 && < 1.1,+ process >= 1.0 && < 1.2, time >= 1.1 && < 1.2, xml >= 1.3 && < 1.4, split >= 0.1 && < 0.2,