Changes email validation in c# to use the email address attribute like we do elsewhere in the codebase, adds unit test assertions to verify it validates the new odd email addresses

This commit is contained in:
Shannon
2017-09-27 22:50:47 +10:00
parent 3bbeb6670b
commit 22ff362521
2 changed files with 4 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
using System.Configuration.Provider;
using System.Security.Cryptography;
using System.Text;
@@ -678,8 +679,7 @@ namespace Umbraco.Core.Security
internal static bool IsEmailValid(string email)
{
var pattern = UmbracoConfig.For.UmbracoSettings().Content.EmailRegex;
return Regex.IsMatch(email, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
return new EmailAddressAttribute().IsValid(email);
}
protected internal string EncryptOrHashPassword(string pass, string salt)

View File

@@ -17,6 +17,8 @@ namespace Umbraco.Tests.Strings
Assert.IsTrue(foo.IsValid("futureTLD@somewhere.fooo"));
Assert.IsTrue(foo.IsValid("abc@xyz.financial"));
Assert.IsTrue(foo.IsValid("admin+gmail-syntax@c.pizza"));
Assert.IsTrue(foo.IsValid("admin@c.pizza"));
Assert.IsFalse(foo.IsValid("fdsa"));
Assert.IsFalse(foo.IsValid("fdsa@"));