1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed validation of email addresses when the local part contains an @.

See also BaseUserManager.normalize_email -- it uses rsplit.

Refs #4833.
This commit is contained in:
Aymeric Augustin 2013-01-26 12:19:31 +01:00
parent 58062a6302
commit 424eb67867
2 changed files with 2 additions and 1 deletions

View File

@ -106,7 +106,7 @@ class EmailValidator(object):
if not value or '@' not in value:
raise ValidationError(self.message, code=self.code)
user_part, domain_part = value.split('@', 1)
user_part, domain_part = value.rsplit('@', 1)
if not self.user_regex.match(user_part):
raise ValidationError(self.message, code=self.code)

View File

@ -31,6 +31,7 @@ TEST_DATA = (
(validate_email, 'test@domain.with.idn.tld.उदाहरण.परीक्षा', None),
(validate_email, 'email@localhost', None),
(EmailValidator(whitelist=['localdomain']), 'email@localdomain', None),
(validate_email, '"test@test"@example.com', None),
(validate_email, None, ValidationError),
(validate_email, '', ValidationError),