#11907 closed (fixed)
EmailField should run strip()
| Reported by: | whatcould | Owned by: | Chris Beaven |
|---|---|---|---|
| Component: | Forms | Version: | 1.1 |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The EmailField should run strip() to remove opening and trailing spaces before the validation is run. Copying and pasting an email can easily pick up a trailing space (I did it myself today).
The code would be something like this, from forms.fields.EmailField. (My first python, sorry if it's ugly, I'm a rubyist.)
def clean(self, value):
value = value.strip()
value = super(RegexField, self).clean(value)
return value
Attachments (3)
Change History (22)
comment:1 by , 16 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
comment:2 by , 16 years ago
| Resolution: | duplicate |
|---|---|
| Status: | closed → reopened |
This is clearly not a duplicate of #6362. Email is a specific kind of data -- #6362 is the general case. (Which, of course, should also be changed, but that's not the point here.)
Emails can not have spaces, so the email. Nothing to do with stripping spaces for other field types.
If the argument against #6362 is that sometimes you might want spaces in the data, that argument is moot here, because you would never want spaces in a user-entered email address. The examples people brought up in #6362, appropriately enough, are of users entering emails (with spaces) and being confused/frustrated.
comment:3 by , 16 years ago
| milestone: | → 1.2 |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:4 by , 16 years ago
| Owner: | changed from to |
|---|---|
| Status: | reopened → new |
comment:5 by , 16 years ago
| Has patch: | set |
|---|---|
| Needs documentation: | set |
| Needs tests: | set |
comment:6 by , 16 years ago
| Has patch: | unset |
|---|---|
| Needs documentation: | unset |
| Needs tests: | unset |
| Owner: | changed from to |
comment:7 by , 16 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:8 by , 16 years ago
| Has patch: | set |
|---|---|
| Needs documentation: | set |
| Needs tests: | set |
comment:9 by , 16 years ago
| Needs documentation: | unset |
|---|---|
| Needs tests: | unset |
| Resolution: | → fixed |
| Status: | assigned → closed |
Added fix based on krisneuharth's diff. Added test.
comment:10 by , 16 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
No patch was committed to Django, tickets are not fixed when a patch is uploaded.
comment:11 by , 16 years ago
| milestone: | 1.2 |
|---|
1.2 is feature-frozen, moving this feature request off the milestone.
comment:12 by , 16 years ago
This sounds a lot like a bug to me, James, not a feature. Emails are emails, and should be formatted as such. Why do you call the thing "email field" anyway if you let any old spaces in?
I'd wager users who try to enter emails, include an incidental space, and then can't log in -- they think it's a bug.
comment:13 by , 16 years ago
Well... actually it's part of (and thus now being closed as a duplicate of) #6362, which asks for whitespace stripping to be applied before validating data in all text-based field types. And that's definitely a feature request, so once again there's no way for this to make it into 1.2. The best way to advance this is to hold on for a bit while 1.2 gets out the door, then lobby for it to get into 1.3.
comment:14 by , 16 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | reopened → closed |
comment:15 by , 16 years ago
ubernostrum, if you see my comment above (02/04/10 00:25:26) I explained why this should be marked as a separate bug, instead of being thrown into the 2-year-old black hole that is that other bug. Someone else apparently agreed at the time.
This is all no skin off my back (I was consulting on a django project that's finished) -- I was just trying to follow through on this bug. Wish it hadn't felt like pushing on a string.
-whatcould (fellow joyeur)
comment:16 by , 15 years ago
| Resolution: | duplicate |
|---|---|
| Status: | closed → reopened |
by , 15 years ago
| Attachment: | 11907.3.diff added |
|---|
comment:17 by , 15 years ago
| Owner: | changed from to |
|---|---|
| Status: | reopened → new |
| Triage Stage: | Accepted → Ready for checkin |
comment:18 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Duplicate of #6362