handle empty input string in mkPass

This commit is contained in:
Jonathan Lamothe committed 2019-01-01 22:50:16 -05:00
1 parent cdff8c8917
commit 012486c045
1 file changed
+4 -3
+4 -3
View File
@@ -323,10 +323,11 @@ 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'
else let p' = nextPolicy x p in
if validatePWPolicy p'
then x : mkPass xs p'
else mkPass xs p