diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-01-26 12:19:31 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-01-26 12:20:57 +0100 |
| commit | 424eb67867162032d92e0bfe3403f051765de805 (patch) | |
| tree | 17ecdc91889387051a4c840389f07ad9a9dbe3cc | |
| parent | 58062a6302a2bf1013d100deb053ccae2298bb84 (diff) | |
Fixed validation of email addresses when the local part contains an @.
See also BaseUserManager.normalize_email -- it uses rsplit.
Refs #4833.
| -rw-r--r-- | django/core/validators.py | 2 | ||||
| -rw-r--r-- | tests/modeltests/validators/tests.py | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index cd9dba1ee8..f094b7bf07 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -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) diff --git a/tests/modeltests/validators/tests.py b/tests/modeltests/validators/tests.py index 5b562a87e6..6b46c53cc3 100644 --- a/tests/modeltests/validators/tests.py +++ b/tests/modeltests/validators/tests.py @@ -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), |
