Skip to content

Commit 1c35e03

Browse files
authored
fix(server): email address validation (#1074)
1 parent 358d34f commit 1c35e03

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Distribution/Server/Util/Validators.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ guardValidLookingEmail str = either errBadEmail return $ do
3030
guard (T.all (not.isAngle) str) ?! "Please use just the email address, not \"name\" <[email protected]> style."
3131
where
3232
isAngle c = c == '<' || c == '>'
33-
hasAtSomewhere =
34-
let (before, after) = T.span (/= '@') str
35-
in T.length before >= 1
36-
&& T.length after > 1
37-
&& not ('@' `T.elem` after)
33+
hasAtSomewhere = case T.span (/= '@') str of
34+
(before, rest)
35+
| Just (_, after) <- T.uncons rest ->
36+
T.length before >= 1
37+
&& T.length after > 0
38+
&& not ('@' `T.elem` after)
39+
_ -> False
3840

3941
errBadUserName, errBadRealName, errBadEmail :: String -> ServerPartE a
4042
errBadUserName err = errBadRequest "Problem with login name" [MText err]

0 commit comments

Comments
 (0)