Skip to content

Commit 3a0440c

Browse files
author
Andreas Fischer
committed
Make e-mail sanity check more precise
1 parent 4562d40 commit 3a0440c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

models/user/email_address.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (err ErrEmailCharIsNotSupported) Error() string {
4141
}
4242

4343
// ErrEmailInvalid represents an error where the email address does not comply with RFC 5322
44+
// or has a leading '-' character
4445
type ErrEmailInvalid struct {
4546
Email string
4647
}
@@ -134,9 +135,7 @@ func ValidateEmail(email string) error {
134135
return ErrEmailCharIsNotSupported{email}
135136
}
136137

137-
if !(email[0] >= 'a' && email[0] <= 'z') &&
138-
!(email[0] >= 'A' && email[0] <= 'Z') &&
139-
!(email[0] >= '0' && email[0] <= '9') {
138+
if email[0] == '-' {
140139
return ErrEmailInvalid{email}
141140
}
142141

0 commit comments

Comments
 (0)