Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: bba63f00 by Mark Sapiro at 2023-09-17T23:27:51+00:00 Properly encode alleged ascii subjects with non-ascii characters. - - - - - 18ff5ed7 by Mark Sapiro at 2023-09-17T23:27:51+00:00 Merge branch 'usrnotice' into 'master' Properly encode alleged ascii subjects with non-ascii characters. Closes #1098 See merge request mailman/mailman!1144 Merged-by: Mark Sapiro <m...@msapiro.net> Reviewed-by: - - - - - 3 changed files: - src/mailman/docs/NEWS.rst - src/mailman/email/message.py - src/mailman/email/tests/test_message.py Changes: ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -56,6 +56,8 @@ Bugs fixed (Closes #1083) * Messages preserved or forwarded by content filtering are now the original message rather than the content filtered one. (Closes #1089) +* List welcome and goodbye messages to users with English preferred_language + now have their Subject: RFC 2047 encoded as needed. (Closes #1098) New Features ------------ ===================================== src/mailman/email/message.py ===================================== @@ -157,6 +157,12 @@ class UserNotification(Message): self.set_payload(text.encode(charset), charset) except UnicodeError: self.set_payload(text.encode(), 'utf-8') + if isinstance(subject, bytes): + subject = subject.decode() + try: + subject.encode(charset, errors='strict') + except UnicodeEncodeError: + charset = 'utf-8' self['Subject'] = Header( subject, charset, header_name='Subject', errors='replace') self['From'] = sender ===================================== src/mailman/email/tests/test_message.py ===================================== @@ -128,6 +128,16 @@ Test content self.assertEqual(msg.get_payload(decode=True).decode(), 'Non-ascii text é.') + def test_ascii_user_notification_non_ascii_subject(self): + msg = UserNotification( + 'aper...@example.com', + 't...@example.com', + 'Something you nééd to know', + 'I needed to tell you this.') + self.assertIn( + b'Subject: =?utf-8?q?Something_you_n=C3=A9=C3=A9d_to_know?=', + msg.as_bytes()) + def test_as_string_python_bug_27321(self): # Bug 27321 is fixed in Python 3.8.7rc1, 3.9.1rc1 and later. with path('mailman.email.tests.data', 'bad_email.eml') as email_path: View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/4bd12376f8dd5b31280cffa2915b73e78355d086...18ff5ed75e5195166d52ec51209bbbd7b3522116 -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/4bd12376f8dd5b31280cffa2915b73e78355d086...18ff5ed75e5195166d52ec51209bbbd7b3522116 You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list -- mailman-checkins@python.org To unsubscribe send an email to mailman-checkins-le...@python.org https://mail.python.org/mailman3/lists/mailman-checkins.python.org/ Member address: arch...@jab.org