Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#12196 closed (invalid)

EmailField reject this email address tosha...99@gmail.com

Reported by: mtsyganov Owned by: nobody
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: UI/UX:

Description (last modified by Alex)

To fix that problem, just change

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

TO

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

in the file django.forms.fields.py

I just replaced in the first line the + to *

Attachments (3)

12196.diff (1.2 KB) - added by simonz05 6 years ago.
12196-2.diff (1.3 KB) - added by JohnDoe 6 years ago.
12196.2.diff (1.5 KB) - added by SmileyChris 5 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 Changed 6 years ago by Alex

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Please use preview.

Changed 6 years ago by simonz05

comment:2 follow-up: Changed 6 years ago by simonz05

  • Has patch set

comment:3 in reply to: ↑ 2 Changed 6 years ago by simonz05

Replying to simonz05:

Fix suggested in description seems to work.
I'm no regex master, though. So for all I know the regex might not be a good solution.

Test are passed .. ok.

So works for me.

Changed 6 years ago by JohnDoe

comment:4 Changed 6 years ago by JohnDoe

I've added another patch, the current one allowed the local-part to end with a dot (see http://tools.ietf.org/html/rfc2822#section-3.4.1 for email specifications).

comment:5 Changed 5 years ago by russellm

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:6 Changed 5 years ago by ubernostrum

  • milestone 1.2 deleted

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

(and yes, asking for more lax email validation is a feature request)

Changed 5 years ago by SmileyChris

comment:7 Changed 5 years ago by SmileyChris

  • Triage Stage changed from Accepted to Ready for checkin

I've updated the patch to use the new EmailValidator.

comment:8 Changed 5 years ago by lukeplant

  • Resolution set to invalid
  • Status changed from new to closed

All the tools I can find that seem to do a decent job of implementing RFC 822 (e.g. http://www.ex-parrot.com/pdw/Mail-RFC822-Address/Mail-RFC822-Address.html and http://www.regular-expressions.info/email.html ) say that "tosha...99@…" is an invalid e-mail address. So I'm closing INVALID - because if we are being even more liberal than RFC 822, we really don't have any standard to reject any e-mail address. Please re-open if you can show that it is a valid e-mail address.

comment:9 Changed 5 years ago by lukeplant

Just to add a bit more - gmail does not even allow you to create e-mail addresses like that - it says "Sorry, your username cannot contain consecutive periods (.)"

comment:10 Changed 5 years ago by JohnDoe

GMail actually ignore dots in emails, e.g. mails to tosha...99@… and tosha99@… will end in the same mailbox. So tosha...99@… WOULD be a valid email address, as it will be mapped to tosha99@… by GMail.

comment:11 Changed 5 years ago by lukeplant

OK, but you can't specify an e-mail address like that when you sign up, and so the 'canonical' form that gmail displays to you will be a form that is accepted by our e-mail validator. So there is no reason to change it.

comment:12 Changed 5 years ago by JohnDoe

Well, except if you're using a provider like hushmail.com who allows all those dots (in signup too).

No matter how you twist it, Django refuses valid emails without this change.

comment:13 Changed 5 years ago by Alex

No, they aren't valid, from Wikipedia: "Character . (dot, period, full stop) provided that it is not the first or last character, and provided also that it does not appear two or more times consecutively (e.g. John..Doe@…)."

comment:14 Changed 5 years ago by ubernostrum

RFC 3696 exists to provide guidance on this topic, and states in section 3: "period (".") may also appear, but may not be used to start or end the local part, nor may two or more consecutive periods appear."

Leaving invalid.

Note: See TracTickets for help on using tickets.
Back to Top