handle empty input string in mkPass

This commit is contained in:
Jonathan Lamothe 2019-01-01 22:50:16 -05:00
parent cdff8c8917
commit 012486c045

View File

@ -323,12 +323,13 @@ isSpecial :: Char -> Bool
isSpecial = not . isAlphaNum isSpecial = not . isAlphaNum
mkPass :: String -> PWPolicy -> String mkPass :: String -> PWPolicy -> String
mkPass (x:xs) p = let p' = nextPolicy x p in mkPass [] _ = "" -- this should never happen
if p^.pwLength <= 0 mkPass (x:xs) p = if p^.pwLength <= 0
then "" then ""
else if validatePWPolicy p' else let p' = nextPolicy x p in
then x : mkPass xs p' if validatePWPolicy p'
else mkPass xs p then x : mkPass xs p'
else mkPass xs p
mkPool :: B.ByteString -> String mkPool :: B.ByteString -> String
mkPool = toB64 . raw where mkPool = toB64 . raw where