1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Make email local-part accept Unicode characters

This commit is contained in:
Julien BERNARD 2022-10-13 15:53:02 -04:00
parent 7c884afe5a
commit 14f58423fd
2 changed files with 6 additions and 1 deletions

View File

@ -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)',

View File

@ -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<script src="x.js">', ValidationError),
(validate_email, "ùnîcódë@valid.com", None),
(validate_email, "统一码@例子.com", None),
(validate_email, "统一码@例子.集团", None),
(validate_email, "يونيكود@مثال.com", None),
(validate_email, "يونيكود@مثال.الجزائر", None),
# Quoted-string format (CR not allowed)
(validate_email, '"\\\011"@here.com', None),
(validate_email, '"\\\012"@here.com', ValidationError),