#33660: EmailMessage encode the subject in base64 when translated and contains
non
US-ASCII characters
-------------------------------------+-------------------------------------
Reporter: Yann | Owner: nobody
Type: Bug | Status: closed
Component: Core (Mail) | Version: 4.0
Severity: Normal | Resolution: needsinfo
Keywords: EmailMessage | Triage Stage:
Translation base64 quoted- | Unreviewed
printable |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* status: new => closed
* resolution: => needsinfo
Comment:
Thanks for the report. However I cannot reproduce this issue with the
following test:
{{{#!diff
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 183a0c0ab1..81921e9504 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -28,7 +28,7 @@ from django.core.mail.backends import console, dummy,
filebased, locmem, smtp
from django.core.mail.message import BadHeaderError, sanitize_address
from django.test import SimpleTestCase, override_settings
from django.test.utils import requires_tz_support
-from django.utils.translation import gettext_lazy
+from django.utils.translation import gettext_lazy, override
from django.utils.version import PY311
try:
@@ -1232,6 +1232,27 @@ class BaseEmailBackendTests(HeadersCheckMixin):
message.get_payload(decode=True).decode(), "Je t'aime très
fort"
)
+
+ def test_send_unicode_lazy(self):
+ email = EmailMessage(
+ gettext_lazy("Password reset"),
+ gettext_lazy("Password reset sent"),
+ "[email protected]",
+ ["[email protected]"],
+ )
+ with override("fr"):
+ num_sent = mail.get_connection().send_messages([email])
+ self.assertEqual(num_sent, 1)
+ message = self.get_the_message()
+ self.assertEqual(
+ message["subject"],
+ "=?utf-8?q?R=C3=A9initialisation_du_mot_de_passe?=",
+ )
+ self.assertEqual(
+ message.get_payload(decode=True).decode(),
+ "Message de réinitialisation du mot de passe envoyé",
+ )
+
def test_send_long_lines(self):
"""
Email line length is limited to 998 chars by the RFC:
}}}
Can you provide a sample project or a test case?
--
Ticket URL: <https://code.djangoproject.com/ticket/33660#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701805f34a8a1-5f1e44ae-0615-4d23-833b-6c2ff9ca793c-000000%40eu-central-1.amazonses.com.