Opened 6 years ago
Closed 6 years ago
#29830 closed Bug (fixed)
EmailMessage may ignore quote printable encoding
Reported by: | Jannik Schürg | Owned by: | nobody |
---|---|---|---|
Component: | Core (Mail) | Version: | dev |
Severity: | Normal | Keywords: | email, mail, encoding |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I want to change the body encoding (base64, quoted-printible) of an email. Example code:
from email import charset from django.core.mail import EmailMessage msg = EmailMessage("Subject", "Hello World") encoding = charset.Charset("utf-8") encoding.body_encoding = charset.QP msg.encoding = encoding print(msg) # Is not encoded with quoted-printables
The quoted-printible encoding in this case is overwritten in SafeMIMEText
. The encoding
property of EmailMessage
seems not to be documented? I attached a patch which changes the bahvior of SafeMIMEText for the case a email.charset.Charset
object was given.
Another idea is to add a new property to EmailMessage.__init__
which allows to set the body encoding.
Versions 1.11 through master are affected.
Attachments (1)
Change History (7)
by , 6 years ago
Attachment: | patch.diff added |
---|
comment:1 by , 6 years ago
Description: | modified (diff) |
---|
comment:2 by , 6 years ago
Component: | Uncategorized → Core (Mail) |
---|---|
Has patch: | unset |
Summary: | EmailMessage does not respect body encoding → EmailMessage may ignore quote printable encoding |
Type: | New feature → Bug |
comment:3 by , 6 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 6 years ago
I have openend a pull request: https://github.com/django/django/pull/10526
comment:5 by , 6 years ago
Has patch: | set |
---|
Looks like the bug is in SafeMIMEText.set_payload(). The quoted-printable encodeding is dropped if the message doesn't have any "long lines."