Permalink
Browse files

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

See also BaseUserManager.normalize_email -- it uses rsplit.

Refs #4833.
  • Loading branch information...
aaugustin committed Jan 26, 2013
1 parent 58062a6 commit 424eb67867162032d92e0bfe3403f051765de805
Showing with 2 additions and 1 deletion.
  1. +1 −1 django/core/validators.py
  2. +1 −0 tests/modeltests/validators/tests.py
@@ -106,7 +106,7 @@ def __call__(self, value):
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)
@@ -31,6 +31,7 @@
(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),

1 comment on commit 424eb67

Contributor

mattseymour commented on 424eb67 Oct 6, 2016

👍

Please sign in to comment.