mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 13:38:13 -05:00
Check for ascii-only in entire local part of emails (#2072)
This commit is contained in:
parent
f2a02e040c
commit
d918f5aae3
@ -41,7 +41,7 @@ namespace Bit.Core.Utilities
|
|||||||
* Must end in a letter (including unicode)
|
* Must end in a letter (including unicode)
|
||||||
See the unit tests for examples of what is allowed.
|
See the unit tests for examples of what is allowed.
|
||||||
**/
|
**/
|
||||||
var emailFormat = @"[\x00-\x7F]+@.+\.\p{L}+$";
|
var emailFormat = @"^[\x00-\x7F]+@.+\.\p{L}+$";
|
||||||
if (!Regex.IsMatch(emailAddress, emailFormat))
|
if (!Regex.IsMatch(emailAddress, emailFormat))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -45,7 +45,8 @@ namespace Bit.Core.Test.Utilities
|
|||||||
[InlineData("hellothere@.worldcom")] // domain beginning with dot
|
[InlineData("hellothere@.worldcom")] // domain beginning with dot
|
||||||
[InlineData("hellothere@worldcom.")] // domain ending in dot
|
[InlineData("hellothere@worldcom.")] // domain ending in dot
|
||||||
[InlineData("hellothere@world.com-")] // domain ending in hyphen
|
[InlineData("hellothere@world.com-")] // domain ending in hyphen
|
||||||
[InlineData("héllö@world.com")] // unicode in local-part
|
[InlineData("hellö@world.com")] // unicode at end of local-part
|
||||||
|
[InlineData("héllo@world.com")] // unicode in middle of local-part
|
||||||
public void IsValid_ReturnsFalseWhenInvalid(string email)
|
public void IsValid_ReturnsFalseWhenInvalid(string email)
|
||||||
{
|
{
|
||||||
var sut = new StrictEmailAddressAttribute();
|
var sut = new StrictEmailAddressAttribute();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user