avoid parseDuration succeeding on empty string
authorJoey Hess <joeyh@joeyh.name>
Tue, 8 Dec 2020 16:51:56 +0000 (12:51 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 8 Dec 2020 16:51:56 +0000 (12:51 -0400)
Utility/HumanTime.hs

index 7db100801585de10591239d65d982f8e6bfa80bd..5178531cf8ce2be0ab6541a4ba2a4b48398829a9 100644 (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