Reject only .. and . (#13)
This commit is contained in:
parent
47450b5dd6
commit
04608e0e53
@ -117,7 +117,7 @@ parseRelDir filepath =
|
|||||||
not ("~/" `isPrefixOf` filepath) &&
|
not ("~/" `isPrefixOf` filepath) &&
|
||||||
not (hasParentDir filepath) &&
|
not (hasParentDir filepath) &&
|
||||||
not (null (normalizeDir filepath)) &&
|
not (null (normalizeDir filepath)) &&
|
||||||
not (all (== '.') filepath) &&
|
filepath /= "." && filepath /= ".." &&
|
||||||
FilePath.isValid filepath
|
FilePath.isValid filepath
|
||||||
then return (Path (normalizeDir filepath))
|
then return (Path (normalizeDir filepath))
|
||||||
else throwM (InvalidRelDir filepath)
|
else throwM (InvalidRelDir filepath)
|
||||||
@ -134,7 +134,7 @@ parseAbsFile filepath =
|
|||||||
not ("~/" `isPrefixOf` filepath) &&
|
not ("~/" `isPrefixOf` filepath) &&
|
||||||
not (hasParentDir filepath) &&
|
not (hasParentDir filepath) &&
|
||||||
not (null (normalizeFile filepath)) &&
|
not (null (normalizeFile filepath)) &&
|
||||||
not (all (== '.') filepath) &&
|
filepath /= "." && filepath /= ".." &&
|
||||||
FilePath.isValid filepath
|
FilePath.isValid filepath
|
||||||
then return (Path (normalizeFile filepath))
|
then return (Path (normalizeFile filepath))
|
||||||
else throwM (InvalidAbsFile filepath)
|
else throwM (InvalidAbsFile filepath)
|
||||||
@ -154,7 +154,7 @@ parseRelFile filepath =
|
|||||||
not ("~/" `isPrefixOf` filepath) &&
|
not ("~/" `isPrefixOf` filepath) &&
|
||||||
not (hasParentDir filepath) &&
|
not (hasParentDir filepath) &&
|
||||||
not (null (normalizeFile filepath)) &&
|
not (null (normalizeFile filepath)) &&
|
||||||
not (all (== '.') filepath) &&
|
filepath /= "." && filepath /= ".." &&
|
||||||
FilePath.isValid filepath
|
FilePath.isValid filepath
|
||||||
then return (Path (normalizeFile filepath))
|
then return (Path (normalizeFile filepath))
|
||||||
else throwM (InvalidRelFile filepath)
|
else throwM (InvalidRelFile filepath)
|
||||||
|
@ -156,6 +156,7 @@ parseRelDirSpec =
|
|||||||
failing "///foo//bar//mu/"
|
failing "///foo//bar//mu/"
|
||||||
failing "///foo//bar////mu"
|
failing "///foo//bar////mu"
|
||||||
failing "///foo//bar/.//mu"
|
failing "///foo//bar/.//mu"
|
||||||
|
succeeding "..." (Path "...")
|
||||||
succeeding "foo.bak" (Path "foo.bak/")
|
succeeding "foo.bak" (Path "foo.bak/")
|
||||||
succeeding "./foo" (Path "foo/")
|
succeeding "./foo" (Path "foo/")
|
||||||
succeeding "././foo" (Path "foo/")
|
succeeding "././foo" (Path "foo/")
|
||||||
@ -176,6 +177,7 @@ parseAbsFileSpec =
|
|||||||
failing "/"
|
failing "/"
|
||||||
failing "//"
|
failing "//"
|
||||||
failing "///foo//bar//mu/"
|
failing "///foo//bar//mu/"
|
||||||
|
succeeding "..." (Path "...")
|
||||||
succeeding "/foo.txt" (Path "/foo.txt")
|
succeeding "/foo.txt" (Path "/foo.txt")
|
||||||
succeeding "///foo//bar////mu.txt" (Path "/foo/bar/mu.txt")
|
succeeding "///foo//bar////mu.txt" (Path "/foo/bar/mu.txt")
|
||||||
succeeding "///foo//bar/.//mu.txt" (Path "/foo/bar/mu.txt")
|
succeeding "///foo//bar/.//mu.txt" (Path "/foo/bar/mu.txt")
|
||||||
@ -195,6 +197,7 @@ parseRelFileSpec =
|
|||||||
failing "///foo//bar//mu/"
|
failing "///foo//bar//mu/"
|
||||||
failing "///foo//bar////mu"
|
failing "///foo//bar////mu"
|
||||||
failing "///foo//bar/.//mu"
|
failing "///foo//bar/.//mu"
|
||||||
|
succeeding "..." (Path "...")
|
||||||
succeeding "foo.txt" (Path "foo.txt")
|
succeeding "foo.txt" (Path "foo.txt")
|
||||||
succeeding "./foo.txt" (Path "foo.txt")
|
succeeding "./foo.txt" (Path "foo.txt")
|
||||||
succeeding "././foo.txt" (Path "foo.txt")
|
succeeding "././foo.txt" (Path "foo.txt")
|
||||||
|
Loading…
Reference in New Issue
Block a user