Skip to content

Commit

Permalink
Fix SafeMIMEText.set_payload() crash on Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Jul 3, 2024
1 parent e0605bb commit 0300001
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion flask_mailman/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ 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 for line in payload.splitlines())
has_long_lines = any(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
# lines, if any (#22561).
charset = utf8_charset_qp if has_long_lines else utf8_charset
Expand Down

0 comments on commit 0300001

Please sign in to comment.