From 012486c045784739cd71ae7a3b14bd29356bf6c3 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 1 Jan 2019 22:50:16 -0500 Subject: [PATCH] handle empty input string in mkPass --- src/Password.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Password.hs b/src/Password.hs index ce2d0e3..1e781da 100644 --- a/src/Password.hs +++ b/src/Password.hs @@ -323,12 +323,13 @@ isSpecial :: Char -> Bool isSpecial = not . isAlphaNum mkPass :: String -> PWPolicy -> String -mkPass (x:xs) p = let p' = nextPolicy x p in - if p^.pwLength <= 0 +mkPass [] _ = "" -- this should never happen +mkPass (x:xs) p = if p^.pwLength <= 0 then "" - else if validatePWPolicy p' - then x : mkPass xs p' - else mkPass xs p + else let p' = nextPolicy x p in + if validatePWPolicy p' + then x : mkPass xs p' + else mkPass xs p mkPool :: B.ByteString -> String mkPool = toB64 . raw where