Skip to content

Commit

Permalink
Updated email address pattern to allow +
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmine committed Feb 28, 2023
1 parent 877c127 commit 912d103
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
1 change: 1 addition & 0 deletions Celeste_Launcher_Gui/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Celeste_Public_Api.Helpers;

namespace Celeste_Launcher_Gui
{
Expand Down
2 changes: 1 addition & 1 deletion Celeste_Launcher_Gui/Pages/LoginPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private async void PerformLogin(object sender, RoutedEventArgs e)
return;
}

if (!Misc.IsValidEmailAdress(email))
if (!Misc.IsValidEmailAddress(email))
{
GenericMessageDialog.Show($"{Properties.Resources.LoginBadEmail}", DialogIcon.Error, DialogOptions.Ok);
return;
Expand Down
4 changes: 2 additions & 2 deletions Celeste_Launcher_Gui/Pages/RegisterPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private void OnResendVerificationKey(object sender, RoutedEventArgs args)

private async void OnVerifyEmail(object sender, RoutedEventArgs args)
{
if (!Misc.IsValidEmailAdress(EmailField.InputContent))
if (!Misc.IsValidEmailAddress(EmailField.InputContent))
{
GenericMessageDialog.Show(Properties.Resources.RegisterInvalidEmail, DialogIcon.Error);
return;
Expand Down Expand Up @@ -69,7 +69,7 @@ private async void OnRegister(object sender, RoutedEventArgs args)
return;
}

if (!Misc.IsValidEmailAdress(EmailField.InputContent))
if (!Misc.IsValidEmailAddress(EmailField.InputContent))
{
GenericMessageDialog.Show(Properties.Resources.RegisterInvalidEmail, DialogIcon.Error);
return;
Expand Down
4 changes: 2 additions & 2 deletions Celeste_Launcher_Gui/Windows/ResetPasswordDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private void CloseWindow(object sender, RoutedEventArgs e)

private async void OnResetPasswordClick(object sender, RoutedEventArgs e)
{
if (!Misc.IsValidEmailAdress(EmailAddressField.InputContent))
if (!Misc.IsValidEmailAddress(EmailAddressField.InputContent))
{
GenericMessageDialog.Show(Properties.Resources.ResetPasswordInvalidEmail, DialogIcon.Error, DialogOptions.Ok);
return;
Expand Down Expand Up @@ -72,7 +72,7 @@ private async void OnResetPasswordClick(object sender, RoutedEventArgs e)

private async void OnSendResetKeyClick(object sender, RoutedEventArgs e)
{
if (!Misc.IsValidEmailAdress(EmailAddressField.InputContent))
if (!Misc.IsValidEmailAddress(EmailAddressField.InputContent))
{
GenericMessageDialog.Show(Properties.Resources.ResetPasswordInvalidEmail, DialogIcon.Error, DialogOptions.Ok);
return;
Expand Down
15 changes: 5 additions & 10 deletions Libs/Celeste_Public_Api/Helpers/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ namespace Celeste_Public_Api.Helpers
{
public static class Misc
{
private const string MatchEmailPattern =
@"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
+ @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
+ @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
+ @"([a-zA-Z0-9]+[\w-]+\.)+[a-zA-Z]{1}[a-zA-Z0-9-]{1,23})$";

private const string ValidEmailAddressPattern =
@"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z";

private const string MatchUserNamePattern =
@"^[A-Za-z0-9]{3,15}$";

Expand Down Expand Up @@ -100,9 +95,9 @@ public static void MoveFiles(string originalPath, string destPath, bool doBackup
}
}

public static bool IsValidEmailAdress(string emailAdress)
public static bool IsValidEmailAddress(string emailAddress)
{
return !string.IsNullOrWhiteSpace(emailAdress) && Regex.IsMatch(emailAdress, MatchEmailPattern);
return Regex.IsMatch(emailAddress, ValidEmailAddressPattern, RegexOptions.IgnoreCase);
}

public static bool IsValidUserName(string userName)
Expand Down

0 comments on commit 912d103

Please sign in to comment.