diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-03-15 12:51:40 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-04-10 18:06:34 +0200 |
| commit | 2e6ae1e96a405fc2ac318325956ce276cfb9830c (patch) | |
| tree | 73519fd4738bcd3930b80bea58260adc83addcda | |
| parent | f075a19e856ced33ddfb0e1330b5c277ddb14bfe (diff) | |
[5.0.x] Refs #34900, Refs #35361 -- Fixed SafeMIMEText.set_payload() crash on Python 3.13.
Payloads with surrogates are passed to the set_payload() since
https://github.com/python/cpython/commit/f97f25ef5dfcdfec0d9a359fd970abd139cf3428
Backport of b231bcd19e57267ce1fc21d42d46f0b65fdcfcf8 from main.
| -rw-r--r-- | django/core/mail/message.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/core/mail/message.py b/django/core/mail/message.py index 4f8c93e9e5..205c680561 100644 --- a/django/core/mail/message.py +++ b/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 |
