Reject path consisting of all "." (fixes #13)

Ping @mrkkrp
This commit is contained in:
Chris Done 2016-03-04 14:39:17 +01:00
parent 04fa5d3ea8
commit 2e109c86d8
2 changed files with 4 additions and 3 deletions

View File

@ -116,7 +116,7 @@ parseRelDir filepath =
not ("~/" `isPrefixOf` filepath) && not ("~/" `isPrefixOf` filepath) &&
not (hasParentDir filepath) && not (hasParentDir filepath) &&
not (null (normalizeDir filepath)) && not (null (normalizeDir filepath)) &&
filepath /= ".." not (all (=='.') filepath)
then return (Path (normalizeDir filepath)) then return (Path (normalizeDir filepath))
else throwM (InvalidRelDir filepath) else throwM (InvalidRelDir filepath)
@ -132,7 +132,7 @@ parseAbsFile filepath =
not ("~/" `isPrefixOf` filepath) && not ("~/" `isPrefixOf` filepath) &&
not (hasParentDir filepath) && not (hasParentDir filepath) &&
not (null (normalizeFile filepath)) && not (null (normalizeFile filepath)) &&
filepath /= ".." not (all (=='.') filepath)
then return (Path (normalizeFile filepath)) then return (Path (normalizeFile filepath))
else throwM (InvalidAbsFile filepath) else throwM (InvalidAbsFile filepath)
@ -151,7 +151,7 @@ parseRelFile filepath =
not ("~/" `isPrefixOf` filepath) && not ("~/" `isPrefixOf` filepath) &&
not (hasParentDir filepath) && not (hasParentDir filepath) &&
not (null (normalizeFile filepath)) && not (null (normalizeFile filepath)) &&
filepath /= ".." not (all (=='.') filepath)
then return (Path (normalizeFile filepath)) then return (Path (normalizeFile filepath))
else throwM (InvalidRelFile filepath) else throwM (InvalidRelFile filepath)

View File

@ -38,6 +38,7 @@ restrictions =
parseFails "~/foo/bar" parseFails "~/foo/bar"
parseFails "../" parseFails "../"
parseFails ".." parseFails ".."
parseFails "."
parseFails "/.." parseFails "/.."
parseFails "/foo/../bar/" parseFails "/foo/../bar/"
parseFails "/foo/bar/.." parseFails "/foo/bar/.."