fix bug in dirContains
dirContains "." ".." was incorrectly true because normalize ("." </> "..") = ".." Sponsored-by: Jochen Bartl on Patreon
This commit is contained in:
parent
e8959617b6
commit
b2efbd1cd3
1 changed files with 6 additions and 3 deletions
|
@ -96,7 +96,7 @@ dirContains :: RawFilePath -> RawFilePath -> Bool
|
|||
dirContains a b = a == b
|
||||
|| a' == b'
|
||||
|| (a'' `B.isPrefixOf` b' && avoiddotdotb)
|
||||
|| a' == "." && normalise ("." </> b') == b'
|
||||
|| a' == "." && normalise ("." </> b') == b' && nodotdot b'
|
||||
where
|
||||
a' = norm a
|
||||
a'' = addTrailingPathSeparator a'
|
||||
|
@ -113,8 +113,11 @@ dirContains a b = a == b
|
|||
- a'' is a prefix of b', so all that needs to be done is drop
|
||||
- that prefix, and check if the next path component is ".."
|
||||
-}
|
||||
avoiddotdotb = not $ any (== "..") $
|
||||
splitPath $ B.drop (B.length a'') b'
|
||||
avoiddotdotb = nodotdot $ B.drop (B.length a'') b'
|
||||
|
||||
nodotdot p = all
|
||||
(\s -> dropTrailingPathSeparator s /= "..")
|
||||
(splitPath p)
|
||||
|
||||
{- Given an original list of paths, and an expanded list derived from it,
|
||||
- which may be arbitrarily reordered, generates a list of lists, where
|
||||
|
|
Loading…
Reference in a new issue