Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15042 closed (fixed)

1.2.4 regression: send_mail doesn't access email recipient with no domain

Reported by: net147 Owned by: lrekucki
Component: Core (Mail) Version: 1.2
Severity: Keywords: blocker regression send_mail email
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Sending email using django.core.mail.send_mail fails to send to an email recipient that is just the username on the current system (e.g. joe instead of joe@localhost).
This worked fine in Django 1.2.3 but no longer works in Django 1.2.4 (throws a ValueError trying to split the email by @ into name and domain).

Attachments (2)

15043.diff (832 bytes) - added by lrekucki 3 years ago.
Patch against trunk.
ticket15042.diff (38.7 KB) - added by lrekucki 3 years ago.
The right patch against trunk.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 3 years ago by russellm

  • Keywords blocker added
  • milestone set to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

To clarify - this only affects the SMTP backend. Code was broken by r15006, fixing #14301, because there's no existing test for the behavior described.

Mail tests should probably be backend-duplicated like the tests for cache backends.

comment:2 Changed 3 years ago by lrekucki

  • Owner changed from nobody to lrekucki

Started refactoring of regressiontests/mail/tests.py. Shouldn't take long.

Changed 3 years ago by lrekucki

Patch against trunk.

Changed 3 years ago by lrekucki

The right patch against trunk.

comment:3 Changed 3 years ago by lrekucki

  • Has patch set

The patch contains:

  • Refactored tests for mail handling:
    • MailTests class contains test cases related to EmailMessage class that don't depend on any backend.
    • BaseEmailBackendTests contains all other tests that involve actually sending any messages.
    • FakeSMTPServer using Python's smptd module for testing the SMTP backend. This runs in another thread for the duration of the testcase.
  • Correct handling of IDN: all headers that contain email addresses must be sanitized properly. Otherwise, the whole header will be encoded as "quoted-printable", thus loosing it's structure. I tried sending some emails to a localy defined IDN and Postfix treats the value in From: =?utf-8?b?ZnLDtm1Aw7bDpMO8LmNvbQ==?= as it was a mailbox name.
  • Some support for non-ASCII characters in local-part of the email (they're encoded as they we're before).
  • A fix and a regression test for this issue.


Note: Backporting to 1.2.X involves moving some code from setUpClass/tearDownClass in SMTPBackendTests to setUp/tearDown. Should I make a seperate patch ?


comment:4 Changed 3 years ago by russellm

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

(In [15211]) Fixed #15042 -- Ensured that email addresses without a domain can still be mail recipients. Patch also improves the IDN handling introduced by r15006, and refactors the test suite to ensure even feature coverage. Thanks to net147 for the report, and to Łukasz Rekucki for the awesome patch.

comment:5 Changed 3 years ago by russellm

(In [15213]) [1.2.X] Fixed #15042 -- Ensured that email addresses without a domain can still be mail recipients. Patch also improves the IDN handling introduced by r15006, and refactors the test suite to ensure even feature coverage. Thanks to net147 for the report, and to Łukasz Rekucki for the awesome patch.

Backport of r15211 from trunk.

comment:6 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.