New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #27029 -- Fixed EmailValidator to allow non-ASCII characters in local part of the address. #7039

wants to merge 1 commit into
base: master
Jump to file or symbol
Failed to load files and symbols.
+11 −2
Diff settings


Just for now

Fixed #27029 -- Supported non-ASCII characters in local part of email…

… addresses

Thanks Tim Graham for the review.
  • Loading branch information...
claudep committed Aug 7, 2016
commit 2fd6c41461fbcb837b24fab2c2626f9d19e65c60
@@ -171,9 +171,10 @@ class EmailValidator(object):
message = _('Enter a valid email address.')
code = 'invalid'
user_regex = _lazy_re_compile(
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*\Z" # dot-atom
r"(^[-!#$%&'*+/=?^`{}|~\w]+(\.[-!#$%&'*+/=?^`{}|~\w]+)*\Z" # dot-atom
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"\Z)', # quoted-string
re.IGNORECASE + (re.UNICODE if six.PY2 else 0)
domain_regex = _lazy_re_compile(
# max length for domain name labels is 63 characters per RFC 1034
@@ -125,6 +125,10 @@ to, or in lieu of custom ``field.clean()`` methods.
:param code: If not ``None``, overrides :attr:`code`.
:param whitelist: If not ``None``, overrides :attr:`whitelist`.
.. versionchanged:: 1.11
Non-ASCII characters are now allowed in the local part of the address.
.. attribute:: message
The error message used by
@@ -282,6 +282,9 @@ Validators
:data:`~django.core.validators.validate_image_file_extension` to validate
image files.
* :class:`~django.core.validators.EmailValidator` now allows non-ASCII
characters in the local part of the email address (as per :rfc:`6530`).
.. _backwards-incompatible-1.11:
Backwards incompatible changes in 1.11
@@ -54,6 +54,7 @@
(validate_email, '', None),
(validate_email, '', None),
(validate_email, 'test@domain.with.idn.tld.उदाहरण.परीक्षा', None),
(validate_email, 'うえあいお', None),
(validate_email, 'email@localhost', None),
(EmailValidator(whitelist=['localdomain']), 'email@localdomain', None),
(validate_email, '"test@test"', None),
ProTip! Use n and p to navigate between commits in a pull request.