From 11b7b9ad0040cbe78d17514373475ee41179d3fa Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 20 Jul 2013 18:00:23 +0200 Subject: [PATCH] Fixed an email validation regression Thanks Vincent Wagelaar for the report. --- django/core/validators.py | 2 +- tests/validators/tests.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django/core/validators.py b/django/core/validators.py index 200d28fe02..aa417ed099 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -87,7 +87,7 @@ class EmailValidator(object): r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)', # quoted-string re.IGNORECASE) domain_regex = re.compile( - r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?$)' # domain + r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,})\.?$' # domain # literal form, ipv4 address (SMTP 4.1.3) r'|^\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE) diff --git a/tests/validators/tests.py b/tests/validators/tests.py index ec3e2dc8c1..9be49d7726 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -46,6 +46,7 @@ TEST_DATA = ( (validate_email, 'example@-invalid.com', ValidationError), (validate_email, 'example@inv-.alid-.com', ValidationError), (validate_email, 'example@inv-.-alid.com', ValidationError), + (validate_email, 'test@example.com\n\n