Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#11144 closed (fixed)

UnicodeEncodeError when unicode characters present in To/From/Cc and also a comma is present

Reported by: anonymous Owned by: nobody
Component: Core (Mail) Version: 1.0
Severity: Keywords: UnicodeEncodeError
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This address will work fine: "Joe Blöggs" <joe.bloggs@…>

However, this address will fail: "Blöggs, Joe" <joe.bloggs@…>

The reason is because Django is doing a simple val.split(",") instead of proper parsing of the addresses.

Bug location: django/core/mail.py:forbid_multi_line_headers line 82 (In 1.0.2 at least)

It's also present in the dev version!

Attachments (2)

bug11144.patch (1002 bytes) - added by rmt 6 years ago.
Use email.Utils.getaddresses instead of toaddrstring.split(",")
bug11144.2.patch (1.6 KB) - added by rmt 6 years ago.
Use email.Utils.getaddresses instead of toaddrstring.split(",") + regression test

Download all attachments as: .zip

Change History (8)

comment:1 Changed 6 years ago by ubernostrum

  • milestone 1.1 deleted
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

So far as I know, Django doesn't attempt to support every address/name format permitted by the RFC. But regardless of the decision on this one, it's not a milestone 1.1 bug -- only critical blockers are being accepted for that now.

Changed 6 years ago by rmt

Use email.Utils.getaddresses instead of toaddrstring.split(",")

comment:2 Changed 6 years ago by rmt

  • Has patch set

Patch attached. Although handling header encoding in a function named forbid_multi_line_headers doesn't seem optimal.

Changed 6 years ago by rmt

Use email.Utils.getaddresses instead of toaddrstring.split(",") + regression test

comment:3 Changed 5 years ago by rmt

  • milestone set to 1.2

Ping? Has anybody looked at this again?

comment:4 Changed 5 years ago by russellm

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

(In [11719]) Fixed #11144 -- When a to/from/cc header contains unicode, make sure the email addresses are parsed correctly (especially with regards to commas). Thanks to rmt for the patch.

comment:5 Changed 5 years ago by russellm

(In [11720]) [1.1.X] Fixed #11144 -- When a to/from/cc header contains unicode, make sure the email addresses are parsed correctly (especially with regards to commas). Thanks to rmt for the patch.

Backport of r11719 from trunk.

comment:6 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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