Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits:
14c9e025 by Mark Sapiro at 2017-12-15T13:07:05-08:00
Replace body characters not in charset in message.UserNotification.
- - - - -
e7e8c1d1 by Mark Sapiro at 2017-12-15T21:30:14+00:00
Merge branch 'issue_437' into 'master'
Replace body characters not in charset in message.UserNotification.
Closes #437
See merge request mailman/mailman!351
- - - - -
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
=====================================
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -46,6 +46,9 @@ Bugs
Message.as_string() to cover more cases than before. (Closes #406)
* The override of Message.as_string() has been extended to catch another
observed exception. (Closes #441)
+* The email.message.UserNotification() constructor will now not fail if given
+ a ``text`` argument containing a character not in the charset of the
+ ``lang`` argument. (Closes #437)
Command line
------------
=====================================
src/mailman/email/message.py
=====================================
--- a/src/mailman/email/message.py
+++ b/src/mailman/email/message.py
@@ -137,7 +137,7 @@ class UserNotification(Message):
charset = (lang.charset if lang is not None else 'us-ascii')
subject = ('(no subject)' if subject is None else subject)
if text is not None:
- self.set_payload(text.encode(charset), charset)
+ self.set_payload(text.encode(charset, errors='replace'), charset)
self['Subject'] = Header(
subject, charset, header_name='Subject', errors='replace')
self['From'] = sender
=====================================
src/mailman/email/tests/test_message.py
=====================================
--- a/src/mailman/email/tests/test_message.py
+++ b/src/mailman/email/tests/test_message.py
@@ -91,6 +91,14 @@ Test content
# Make sure the senders property does not fail
self.assertEqual(msg.senders, ['[email protected]'])
+ def test_user_notification_bad_charset(self):
+ msg = UserNotification(
+ '[email protected]',
+ '[email protected]',
+ 'Something you need to know',
+ 'Non-ascii text é.')
+ self.assertEqual(msg.get_payload(), 'Non-ascii text ?.')
+
def test_as_string_python_bug_27321(self):
email_path = resource_filename(
'mailman.email.tests.data', 'bad_email.eml')
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/af91900c20302dfda9e967d050386264a3cd59ff...e7e8c1d1de5bc0a18823fb4dd3fc7e7ad995480e
---
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/af91900c20302dfda9e967d050386264a3cd59ff...e7e8c1d1de5bc0a18823fb4dd3fc7e7ad995480e
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org