python-Django/fix-safemimetext-set_payload.patch

15 lines
764 B
Diff

Index: Django-4.2.11/django/core/mail/message.py
===================================================================
--- Django-4.2.11.orig/django/core/mail/message.py
+++ Django-4.2.11/django/core/mail/message.py
@@ -168,7 +168,8 @@ class SafeMIMEText(MIMEMixin, MIMEText):
def set_payload(self, payload, charset=None):
if charset == "utf-8" and not isinstance(charset, Charset.Charset):
has_long_lines = any(
- len(line.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT
+ len(line.encode(errors="surrogateescape"))
+ > RFC5322_EMAIL_LINE_LENGTH_LIMIT
for line in payload.splitlines()
)
# Quoted-Printable encoding has the side effect of shortening long