Django

Code

Ticket #11212 (new)

Opened 9 months ago

Last modified 1 week ago

Don't encode emails with base64/qp

Reported by: phr Assigned to: nobody
Milestone: 1.2 Component: django.core.mail
Version: SVN Keywords: send_mail
Cc: petr.hroudny@gmail.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 1 Patch needs improvement: 0

Description

#3472 introduced a patch, which replaces base64 encoding with quoted-printable.

Anyway, there's even better way to do get rid of unnecessary encoding:

from email import Charset 
Charset.add_charset('utf-8',Charset.SHORTEST,None,'utf-8')

The above will set Content-Transfer-Encoding to 7bit or 8bit as needed - exactly as Mutt or Thunderbird do and completely solve the problem even for non-latin characters.

Attachments

Change History

05/27/09 01:57:33 changed by phr

  • cc changed from phr to petr.hroudny@gmail.com.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

05/27/09 02:20:15 changed by russellm

  • needs_tests set to 1.

Tests aren't optional. If you're changing code, you need tests - or a good excuse why a test isn't possible.

06/08/09 10:33:11 changed by phr

I'm not quite sure what to test here. Only a single parameter needs to be changed in file django/core/mail.py at line 23:

-Charset.add_charset('utf-8', Charset.SHORTEST, Charset.QP, 'utf-8')
+Charset.add_charset('utf-8', Charset.SHORTEST, None, 'utf-8')

09/11/09 06:12:10 changed by lukeplant

You need to update and add to the tests in tests/regressiontests/mail/tests.py, which fail with the above change. You should add tests that show what happens with 7bit and 8bit data.

09/11/09 10:56:19 changed by phr

Yes, sure those tests fail. They test for:

Content-Transfer-Encoding: quoted-printable

at multiple places, which after the proposed change will not pass. If the input is pure ascii, that header will become:

Content-Transfer-Encoding: 7bit

If the input contains some accentuated character - e.g. 'áéí', there will be 8bit instead.

02/02/10 06:09:05 changed by russellm

  • stage changed from Unreviewed to Accepted.
  • milestone set to 1.2.

Add/Change #11212 (Don't encode emails with base64/qp)




Change Properties
Action