Opened 7 years ago

Closed 6 years ago

Last modified 6 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 Gaynor)

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 Simon Zimmermann 7 years ago.
12196-2.diff (1.3 KB) - added by JohnDoe 7 years ago.
12196.2.diff (1.5 KB) - added by Chris Beaven 6 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 Changed 7 years ago by Alex Gaynor

Description: modified (diff)

Please use preview.

Changed 7 years ago by Simon Zimmermann

Attachment: 12196.diff added

comment:2 Changed 7 years ago by Simon Zimmermann

Has patch: set

comment:3 in reply to:  2 Changed 7 years ago by Simon Zimmermann

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 7 years ago by JohnDoe

Attachment: 12196-2.diff added

comment:4 Changed 7 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 7 years ago by Russell Keith-Magee

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:6 Changed 7 years ago by James Bennett

milestone: 1.2

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 6 years ago by Chris Beaven

Attachment: 12196.2.diff added

comment:7 Changed 6 years ago by Chris Beaven

Triage Stage: AcceptedReady for checkin

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

comment:8 Changed 6 years ago by Luke Plant

Resolution: invalid
Status: newclosed

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 6 years ago by Luke Plant

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 6 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 6 years ago by Luke Plant

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 6 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 6 years ago by Alex Gaynor

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 6 years ago by James Bennett

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