Handle consecutive ".."s in makeCanonical
As an example, prior to this commit, "../../file" would evaluate to "file", when it should be unchanged.
This commit is contained in:
parent
7fbce82f2f
commit
e1f8c4b396
1 changed files with 4 additions and 3 deletions
|
@ -637,9 +637,10 @@ checkExistence fn = do
|
|||
makeCanonical :: FilePath -> FilePath
|
||||
makeCanonical = Posix.joinPath . transformPathParts . splitDirectories
|
||||
where transformPathParts = reverse . foldl' go []
|
||||
go as "." = as
|
||||
go (_:as) ".." = as
|
||||
go as x = x : as
|
||||
go as "." = as
|
||||
go ("..":as) ".." = ["..", ".."] <> as
|
||||
go (_:as) ".." = as
|
||||
go as x = x : as
|
||||
|
||||
-- | Tries to run an action on a file: for each directory given, a
|
||||
-- filepath is created from the given filename, and the action is run on
|
||||
|
|
Loading…
Add table
Reference in a new issue