EmailField rejects valid emails if followed by trailing whitespace
|Reported by:||Eloff||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I just had this issue on a production django site, reported by a customer. The form was rejecting his email address and he did not know why. I confirmed that the email address passes validation just fine, but that he was consistently entering trailing whitespace in the form field that caused it and others to fail validation.
I think the logical thing to do here, since leading and trailing whitespace cannot be significant to an email, and may also cause issues when using the cleaned value, is to override to_python on EmailField to strip() the value. I have hot-patched django in my website to do this, and it has resolved the issue for me.