diff --git a/django/forms/fields.py b/django/forms/fields.py
index 2e6eb82..4793633 100644
a
|
b
|
class EmailField(CharField):
|
414 | 414 | 'invalid': _(u'Enter a valid e-mail address.'), |
415 | 415 | } |
416 | 416 | default_validators = [validators.validate_email] |
| 417 | |
| 418 | def clean(self, value): |
| 419 | if value is None: |
| 420 | value = u'' |
| 421 | value = smart_str(value).strip() |
| 422 | value = super(EmailField, self).clean(value) |
| 423 | return value |
417 | 424 | |
418 | 425 | class FileField(Field): |
419 | 426 | widget = FileInput |
diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py
index 8733090..bff6e70 100644
a
|
b
|
class FieldsTests(TestCase):
|
425 | 425 | self.assertEqual(u'', f.clean('')) |
426 | 426 | self.assertEqual(u'', f.clean(None)) |
427 | 427 | self.assertEqual(u'person@example.com', f.clean('person@example.com')) |
| 428 | self.assertEqual(u'example@example.com', f.clean(' example@example.com \t \t ')) |
428 | 429 | self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo') |
429 | 430 | self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@') |
430 | 431 | self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar') |