Opened 14 years ago

Closed 14 years ago

Last modified 14 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: no UI/UX: no

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

Download all attachments as: .zip

Change History (17)

comment:1 by Alex Gaynor, 14 years ago

Description: modified (diff)

Please use preview.

by Simon Zimmermann, 14 years ago

Attachment: 12196.diff added

comment:2 by Simon Zimmermann, 14 years ago

Has patch: set

in reply to:  2 comment:3 by Simon Zimmermann, 14 years ago

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.

by JohnDoe, 14 years ago

Attachment: 12196-2.diff added

comment:4 by JohnDoe, 14 years ago

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 by Russell Keith-Magee, 14 years ago

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:6 by James Bennett, 14 years ago

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)

by Chris Beaven, 14 years ago

Attachment: 12196.2.diff added

comment:7 by Chris Beaven, 14 years ago

Triage Stage: AcceptedReady for checkin

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

comment:8 by Luke Plant, 14 years ago

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

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

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

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

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

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

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