Django

Code

Ticket #11907 (closed: duplicate)

Opened 6 months ago

Last modified 2 weeks ago

EmailField should run strip()

Reported by: whatcould Assigned to: djansoft
Milestone: Component: Forms
Version: 1.1 Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

11907.diff (0.5 kB) - added by krisneuharth on 02/06/10 16:28:57.
Patch for #11907
11907.2.diff (1.4 kB) - added by djansoft on 02/06/10 19:49:49.
Fix with test.

Change History

01/13/10 05:50:46 changed by mk

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to duplicate.
  • needs_tests changed.
  • needs_docs changed.

Duplicate of #6362

02/04/10 00:25:26 changed by whatcould

  • status changed from closed to reopened.
  • resolution deleted.

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.

02/04/10 06:16:40 changed by russellm

  • stage changed from Unreviewed to Accepted.
  • milestone set to 1.2.

02/06/10 16:28:13 changed by krisneuharth

  • owner changed from nobody to krisneuharth.
  • status changed from reopened to new.

02/06/10 16:28:57 changed by krisneuharth

  • attachment 11907.diff added.

Patch for #11907

02/06/10 16:29:26 changed by krisneuharth

  • needs_docs set to 1.
  • has_patch set to 1.
  • needs_tests set to 1.

02/06/10 17:24:43 changed by krisneuharth

  • owner changed from krisneuharth to nobody.
  • needs_docs deleted.
  • has_patch deleted.
  • needs_tests deleted.

02/06/10 18:05:52 changed by djansoft

  • owner changed from nobody to djansoft.
  • status changed from new to assigned.

02/06/10 18:47:32 changed by djansoft

  • needs_docs set to 1.
  • has_patch set to 1.
  • needs_tests set to 1.

02/06/10 19:49:49 changed by djansoft

  • attachment 11907.2.diff added.

Fix with test.

02/06/10 19:52:14 changed by djansoft

  • status changed from assigned to closed.
  • needs_docs deleted.
  • resolution set to fixed.
  • needs_tests deleted.

Added fix based on krisneuharth's diff. Added test.

02/06/10 19:53:59 changed by Alex

  • status changed from closed to reopened.
  • resolution deleted.

No patch was committed to Django, tickets are not fixed when a patch is uploaded.

02/23/10 18:19:16 changed by ubernostrum

  • milestone deleted.

1.2 is feature-frozen, moving this feature request off the milestone.

02/24/10 00:40:03 changed by whatcould

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.

02/24/10 06:22:22 changed by ubernostrum

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.

02/24/10 06:22:31 changed by ubernostrum

  • status changed from reopened to closed.
  • resolution set to duplicate.

02/24/10 10:14:28 changed by whatcould

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)


Add/Change #11907 (EmailField should run strip())




Change Properties
Action