Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c41fa86d17 | ||
|
|
04608e0e53 | ||
|
|
47450b5dd6 | ||
|
|
540c24f3a5 |
@@ -1,3 +1,7 @@
|
||||
0.5.6:
|
||||
* Reject only .. and .
|
||||
0.5.5:
|
||||
* Use filepath's isValid function for additional sanity checks
|
||||
0.5.4:
|
||||
* Disable parsing of path consisting only of "."
|
||||
* Add NFData instance for Path
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: path
|
||||
version: 0.5.4
|
||||
version: 0.5.6
|
||||
synopsis: Support for well-typed paths
|
||||
description: Support for will-typed paths.
|
||||
license: BSD3
|
||||
|
||||
12
src/Path.hs
12
src/Path.hs
@@ -97,7 +97,8 @@ parseAbsDir filepath =
|
||||
if FilePath.isAbsolute filepath &&
|
||||
not (null (normalizeDir filepath)) &&
|
||||
not ("~/" `isPrefixOf` filepath) &&
|
||||
not (hasParentDir filepath)
|
||||
not (hasParentDir filepath) &&
|
||||
FilePath.isValid filepath
|
||||
then return (Path (normalizeDir filepath))
|
||||
else throwM (InvalidAbsDir filepath)
|
||||
|
||||
@@ -116,7 +117,8 @@ parseRelDir filepath =
|
||||
not ("~/" `isPrefixOf` filepath) &&
|
||||
not (hasParentDir filepath) &&
|
||||
not (null (normalizeDir filepath)) &&
|
||||
not (all (=='.') filepath)
|
||||
filepath /= "." && filepath /= ".." &&
|
||||
FilePath.isValid filepath
|
||||
then return (Path (normalizeDir filepath))
|
||||
else throwM (InvalidRelDir filepath)
|
||||
|
||||
@@ -132,7 +134,8 @@ parseAbsFile filepath =
|
||||
not ("~/" `isPrefixOf` filepath) &&
|
||||
not (hasParentDir filepath) &&
|
||||
not (null (normalizeFile filepath)) &&
|
||||
not (all (=='.') filepath)
|
||||
filepath /= "." && filepath /= ".." &&
|
||||
FilePath.isValid filepath
|
||||
then return (Path (normalizeFile filepath))
|
||||
else throwM (InvalidAbsFile filepath)
|
||||
|
||||
@@ -151,7 +154,8 @@ parseRelFile filepath =
|
||||
not ("~/" `isPrefixOf` filepath) &&
|
||||
not (hasParentDir filepath) &&
|
||||
not (null (normalizeFile filepath)) &&
|
||||
not (all (=='.') filepath)
|
||||
filepath /= "." && filepath /= ".." &&
|
||||
FilePath.isValid filepath
|
||||
then return (Path (normalizeFile filepath))
|
||||
else throwM (InvalidRelFile filepath)
|
||||
|
||||
|
||||
@@ -156,6 +156,7 @@ parseRelDirSpec =
|
||||
failing "///foo//bar//mu/"
|
||||
failing "///foo//bar////mu"
|
||||
failing "///foo//bar/.//mu"
|
||||
succeeding "..." (Path "...")
|
||||
succeeding "foo.bak" (Path "foo.bak/")
|
||||
succeeding "./foo" (Path "foo/")
|
||||
succeeding "././foo" (Path "foo/")
|
||||
@@ -176,6 +177,7 @@ parseAbsFileSpec =
|
||||
failing "/"
|
||||
failing "//"
|
||||
failing "///foo//bar//mu/"
|
||||
succeeding "..." (Path "...")
|
||||
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")
|
||||
@@ -195,6 +197,7 @@ parseRelFileSpec =
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user