avoid parseDuration succeeding on empty string

This commit is contained in:
Joey Hess 2020-12-08 12:51:56 -04:00
parent b9cfd15e90
commit 794fc72afb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -45,7 +45,9 @@ daysToDuration i = Duration $ i * dsecs
{- Parses a human-input time duration, of the form "5h", "1m", "5h1m", etc -}
parseDuration :: String -> Either String Duration
parseDuration d = maybe parsefail (Right . Duration) $ go 0 d
parseDuration d
| null d = parsefail
| otherwise = maybe parsefail (Right . Duration) $ go 0 d
where
go n [] = return n
go n s = do