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:
@@ -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)
|
||||
|
||||
@@ -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@"));
|
||||
|
||||
Reference in New Issue
Block a user