Skip to content

Commit

Permalink
Refs #34900 -- Fixed SafeMIMEText.set_payload() crash on Python 3.13.
Browse files Browse the repository at this point in the history
Payloads with surrogates are passed to the set_payload() since
python/cpython@f97f25e
  • Loading branch information
felixxm committed Mar 15, 2024
1 parent 36a0008 commit b231bcd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/core/mail/message.py
Expand Up @@ -168,7 +168,8 @@ def __setitem__(self, name, val):
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
Expand Down

0 comments on commit b231bcd

Please sign in to comment.