Opened 7 years ago

Closed 6 years ago

Last modified 4 years ago

#9890 closed (fixed)

EmailField bug

Reported by: ozgur Owned by: nobody
Component: Forms Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I have a form like this:

class InvitationForm(forms.Form):
    e_mail = forms.EmailField()

when I test this form;

In [10]: i = InvitationForm(data={"e_mail":"ozgur@gmail-.com"})
In [11]: i.is_valid()
Out[11]: True

However; when I tried to send an email to this email via postfix; I got that error:

ada:~# nc localhost smtp
220 ada.adacor.com.tr ESMTP Postfix (Debian/GNU)
MAIL FROM:can@canb.net
250 2.1.0 Ok
RCPT TO: ozgur@gmail-.com
501 5.1.3 Bad recipient address syntax

The problem is that although django.forms.EmailField accepts "ozgur@…" as a valid email, however, postfix is giving me an error.

Attachments (1)

emailfield-r9692.diff (1.6 KB) - added by kratorius 7 years ago.
patch + tests

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

The email address ozgur@… is completely legal. See RFC822 for more details. If If Postfix has a problem with this address, then that is Postfix's problem, not Django's.

comment:2 Changed 7 years ago by kmtracey

Russell -- are you sure about that? RFC 1035 (listed as obsoleting 822) describes domain names:

The following syntax will result in fewer problems with many
applications that use domain names (e.g., mail, TELNET).

<domain> ::= <subdomain> | " "

<subdomain> ::= <label> | <subdomain> "." <label>

<label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]

<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>

<let-dig-hyp> ::= <let-dig> | "-"

<let-dig> ::= <letter> | <digit>

<letter> ::= any one of the 52 alphabetic characters A through Z in
upper case and a through z in lower case

<digit> ::= any one of the ten digits 0 through 9

Note that while upper and lower case letters are allowed in domain
names, no significance is attached to the case.  That is, two names with
the same spelling but different case are to be treated as if identical.

The labels must follow the rules for ARPANET host names.  They must
start with a letter, end with a letter or digit, and have as interior
characters only letters, digits, and hyphen.  There are also some
restrictions on the length.  Labels must be 63 characters or less.

While the first sentence sounds pretty wishy-washy on whether these are "rules" the last paragraph sounds pretty definite that hyphens are not allowed as the last character of a label.

comment:3 Changed 7 years ago by russellm

  • Resolution invalid deleted
  • Status changed from closed to reopened

Bah - you are correct, Karen. I was mistakenly looking at RFC 822 (format for internet text messages), not 882 (domain names). For what it's worth, 882 also prohibits hyphens at the end of a domain element, as does 821/2821 (SMTP). Reopening; apologies for the confusion ozgur.

Changed 7 years ago by kratorius

patch + tests

comment:4 Changed 7 years ago by kratorius

  • Has patch set

comment:5 Changed 7 years ago by jacob

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

comment:6 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [10573]) Fixed #9890 -- Modified the regex validation for email addresses to match RFC822/1035. Thanks to ozgur for the report, and kratorius for the patch.

comment:7 Changed 6 years ago by russellm

(In [10576]) [1.0.X] Fixed #9890 -- Modified the regex validation for email addresses to match RFC822/1035. Thanks to ozgur for the report, and kratorius for the patch.

Merge of 10573 from trunk.

comment:8 Changed 4 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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