From 14f58423fd6e8e3a67ae071f464d37fe9e15a0b0 Mon Sep 17 00:00:00 2001 From: Julien BERNARD Date: Thu, 13 Oct 2022 15:53:02 -0400 Subject: [PATCH] Make email local-part accept Unicode characters --- django/core/validators.py | 2 +- tests/validators/tests.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/django/core/validators.py b/django/core/validators.py index c73490588d..b8e5ce2fd1 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -176,7 +176,7 @@ class EmailValidator: code = "invalid" user_regex = _lazy_re_compile( # dot-atom - r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\Z" + r"(^[-!#$%&'*+/=?^`{}|~\w]+(\.[-!#$%&'*+/=?^`{}|~\w]+)*\Z" # quoted-string r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])' r'*"\Z)', diff --git a/tests/validators/tests.py b/tests/validators/tests.py index 02bee30ac1..a5feec7b82 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -313,6 +313,11 @@ TEST_DATA = [ (validate_email, "example@inv-.alid-.com", ValidationError), (validate_email, "example@inv-.-alid.com", ValidationError), (validate_email, 'test@example.com\n\n