diff --git a/django/core/validators.py b/django/core/validators.py index 796c57e4b0b..cf5ec7aa778 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -89,7 +89,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 367bd4380dc..e3f418ee73c 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -56,6 +56,7 @@ TEST_DATA = ( # Quoted-string format (CR not allowed) (validate_email, '"\\\011"@here.com', None), (validate_email, '"\\\012"@here.com', ValidationError), + (validate_email, 'trailingdot@shouldfail.com.', ValidationError), (validate_slug, 'slug-ok', None), (validate_slug, 'longer-slug-still-ok', None),