Skip to content

Commit

Permalink
Fix email regex for account creation to accept all 2-letter domains. …
Browse files Browse the repository at this point in the history
…Ensure email validation ignores capitalized characters.
  • Loading branch information
ethanmoffat committed Sep 19, 2022
1 parent 7b603e6 commit 3d932d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions EOLib/Domain/Account/CreateAccountParameterValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EOLib.Domain.Account
[AutoMappedType]
public class CreateAccountParameterValidator : ICreateAccountParameterValidator
{
private const string ValidEmailRegex = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b";
private const string ValidEmailRegex = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b";

public bool AccountNameIsNotLongEnough(string account)
{
Expand Down Expand Up @@ -35,7 +35,7 @@ public bool PasswordIsTooObvious(string password)

public bool EmailIsInvalid(string email)
{
return !System.Text.RegularExpressions.Regex.IsMatch(email, ValidEmailRegex);
return !System.Text.RegularExpressions.Regex.IsMatch(email.ToLowerInvariant(), ValidEmailRegex);
}
}

Expand Down

0 comments on commit 3d932d8

Please sign in to comment.