avoid providing filename with NUL to quickcheck properties
instance Arbitrary [Char] allows that, and it's not a legal part of a filename so can break processing them. Noticed when prop_view_roundtrips failed. The instance Arbitrary AssociatedFile avoids this problem. This commit was sponsored by Mark Reidenbach on Patreon.
This commit is contained in:
parent
1db49497e0
commit
907a0bcad6
2 changed files with 8 additions and 5 deletions
|
@ -88,6 +88,7 @@ upFrom dir
|
|||
prop_upFrom_basics :: FilePath -> Bool
|
||||
prop_upFrom_basics dir
|
||||
| null dir = True
|
||||
| '\NUL' `elem` dir = True -- not a legal filename
|
||||
| dir == "/" = p == Nothing
|
||||
| otherwise = p /= Just dir
|
||||
where
|
||||
|
@ -226,6 +227,7 @@ relPathDirToFileAbs from to
|
|||
prop_relPathDirToFileAbs_basics :: FilePath -> FilePath -> Bool
|
||||
prop_relPathDirToFileAbs_basics from to
|
||||
| null from || null to = True
|
||||
| '\NUL' `elem` from || '\NUL' `elem` to = True -- not a legal filename
|
||||
| from == to = null r
|
||||
| otherwise = not (null r)
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue