diff --git a/django/core/validators.py b/django/core/validators.py
index 796c57e..f07853e 100644
|
a
|
b
|
class EmailValidator(object):
|
| 114 | 114 | if not self.user_regex.match(user_part): |
| 115 | 115 | raise ValidationError(self.message, code=self.code) |
| 116 | 116 | |
| 117 | | if (not domain_part in self.domain_whitelist and |
| 118 | | not self.domain_regex.match(domain_part)): |
| | 117 | def domain_is_invalid(domain): |
| | 118 | return not self.domain_regex.match(domain_part) or domain_part.endswith('.') |
| | 119 | |
| | 120 | if domain_part not in self.domain_whitelist and domain_is_invalid(domain_part): |
| 119 | 121 | # Try for possible IDN domain-part |
| 120 | 122 | try: |
| 121 | 123 | domain_part = domain_part.encode('idna').decode('ascii') |
| 122 | | if not self.domain_regex.match(domain_part): |
| | 124 | if domain_is_invalid(domain_part): |
| 123 | 125 | raise ValidationError(self.message, code=self.code) |
| 124 | 126 | else: |
| 125 | 127 | return |
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index 367bd43..e3f418e 100644
|
a
|
b
|
TEST_DATA = (
|
| 56 | 56 | # Quoted-string format (CR not allowed) |
| 57 | 57 | (validate_email, '"\\\011"@here.com', None), |
| 58 | 58 | (validate_email, '"\\\012"@here.com', ValidationError), |
| | 59 | (validate_email, 'trailingdot@shouldfail.com.', ValidationError), |
| 59 | 60 | |
| 60 | 61 | (validate_slug, 'slug-ok', None), |
| 61 | 62 | (validate_slug, 'longer-slug-still-ok', None), |