From 794fc72afbaab7b49faafc158fe5a064bdb2eb49 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Dec 2020 12:51:56 -0400 Subject: [PATCH] avoid parseDuration succeeding on empty string --- Utility/HumanTime.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Utility/HumanTime.hs b/Utility/HumanTime.hs index 7db1008015..5178531cf8 100644 --- a/Utility/HumanTime.hs +++ b/Utility/HumanTime.hs @@ -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