diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2011-06-10 10:22:42 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2011-06-10 10:22:42 +0000 |
| commit | 66436ad171d8c442037bb03e9bc1a0f99e194ac8 (patch) | |
| tree | e1c09d581aa6563f837683b32c3e0eed0b61da92 | |
| parent | 430b819967054805c49c0a27fb9f039568ee240f (diff) | |
Fixed #16166 - `EmailField` does not comply with SMTP standard
Thanks to qqq1one@yahoo.com for the report, and samufuentes for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16355 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/validators.py | 3 | ||||
| -rw-r--r-- | tests/modeltests/validators/tests.py | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index 74db11697b..0f6adf8fda 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -135,7 +135,8 @@ class EmailValidator(RegexValidator): email_re = re.compile( r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string - r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE) # domain + r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$)' # domain + 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) # literal form, ipv4 address (SMTP 4.1.3) validate_email = EmailValidator(email_re, _(u'Enter a valid e-mail address.'), 'invalid') slug_re = re.compile(r'^[-\w]+$') diff --git a/tests/modeltests/validators/tests.py b/tests/modeltests/validators/tests.py index 08965c618f..cfb7b4b793 100644 --- a/tests/modeltests/validators/tests.py +++ b/tests/modeltests/validators/tests.py @@ -22,12 +22,14 @@ TEST_DATA = ( (validate_email, 'email@here.com', None), (validate_email, 'weirder-email@here.and.there.com', None), + (validate_email, 'email@[127.0.0.1]', None), (validate_email, None, ValidationError), (validate_email, '', ValidationError), (validate_email, 'abc', ValidationError), (validate_email, 'a @x.cz', ValidationError), (validate_email, 'something@@somewhere.com', ValidationError), + (validate_email, 'email@127.0.0.1', ValidationError), (validate_slug, 'slug-ok', None), (validate_slug, 'longer-slug-still-ok', None), |
