Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits:
e0411fbe by Mark Sapiro at 2018-04-29T21:25:15Z
Catch another observed exception in our message.as_string() method.
- - - - -
edf5564c by Mark Sapiro at 2018-04-29T22:08:28Z
Merge branch 'lookup_error' into 'master'
Catch another observed exception in our message.as_string() method.
Closes #470
See merge request mailman/mailman!375
- - - - -
4 changed files:
- src/mailman/docs/NEWS.rst
- src/mailman/email/message.py
- + src/mailman/email/tests/data/bad_email_3.eml
- 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
@@ -67,6 +67,8 @@ Bugs
#439)
* Calling ``set`` on a template evicts the local cache if the template was
cached before. (Closes #463)
+* The override of Message.as_string() has been extended to catch yet another
+ observed exception. (Closes #470)
Command line
------------
=====================================
src/mailman/email/message.py
=====================================
--- a/src/mailman/email/message.py
+++ b/src/mailman/email/message.py
@@ -52,7 +52,7 @@ class Message(email.message.Message):
# https://bugs.python.org/issue32330.
try:
value = email.message.Message.as_string(self)
- except (KeyError, UnicodeEncodeError):
+ except (KeyError, LookupError, UnicodeEncodeError):
value = email.message.Message.as_bytes(self).decode(
'ascii', 'replace')
return value
=====================================
src/mailman/email/tests/data/bad_email_3.eml
=====================================
--- /dev/null
+++ b/src/mailman/email/tests/data/bad_email_3.eml
@@ -0,0 +1,11 @@
+From: A User <[email protected]>
+To: [email protected]
+Subject: [VIS] eBay TechTalk
+Message-ID: <[email protected]
+MIME-version: 1.0
+Content-Type: text/plain; charset="UTF-8"\r\n
+
+Der VIS organisiert zusammen mit eBay einen TechTalk am 03. Mai 2018.
+Nachfolgend findest du alle weiteren Informationen.
+
+Liebe GrĂ¼sse
=====================================
src/mailman/email/tests/test_message.py
=====================================
--- a/src/mailman/email/tests/test_message.py
+++ b/src/mailman/email/tests/test_message.py
@@ -116,3 +116,12 @@ Test content
fp.seek(0)
text = fp.read().decode('ascii', 'replace')
self.assertEqual(msg.as_string(), text)
+
+ def test_bogus_content_charset(self):
+ email_path = resource_filename(
+ 'mailman.email.tests.data', 'bad_email_3.eml')
+ with open(email_path, 'rb') as fp:
+ msg = message_from_binary_file(fp, Message)
+ fp.seek(0)
+ text = fp.read().decode('ascii', 'replace')
+ self.assertEqual(msg.as_string(), text)
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/6e75ca086fb07234dd016da87c3708924493a2c7...edf5564ca85c10fdf843df3b5a3ac1fb8b67c0bd
---
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/6e75ca086fb07234dd016da87c3708924493a2c7...edf5564ca85c10fdf843df3b5a3ac1fb8b67c0bd
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