Commit 057bc070 authored by Barry Warsaw's avatar Barry Warsaw

Squashed commit of the following:

commit 3c6500c2292869f94667520f16c8d6c6f1d2c530
Author: Barry Warsaw <[email protected]>
Date:   Tue Aug 29 22:51:18 2017 -0400

    Close #383

    Messages with badly encoded ``Subject`` headers no longer crash the message
    moderation REST API.

commit f6040ec139bcccd48cfa9acc734cd528a8ede35c
Author: Aurélien Bompard <[email protected]>
Date:   Thu Jul 27 00:52:05 2017 +0200

    Fix #383: email encoding errors can crash the REST API
parent de8c204f
Pipeline #11293911 passed with stage
in 54 minutes and 6 seconds
......@@ -24,6 +24,8 @@ Bugs
* Various message holds and rejects that gave 'N/A' as a reason now give an
appropriate reason. (Closes #368)
* Bounce messages are now composed for proper translations.
* Messages with badly encoded ``Subject`` headers no longer crash the message
moderation REST API. (Closes #383)
Command line
......@@ -95,7 +95,7 @@ class _HeldMessageBase(_ModerationBase):
# Store the original header and then try decoding it.
resource['original_subject'] = resource['subject']
# If we can't decode the header, leave the subject unchanged.
with suppress(LookupError, MessageError):
with suppress(LookupError, MessageError, UnicodeDecodeError):
resource['subject'] = str(
# Also, held message resources will always be this type, so ignore
......@@ -144,6 +144,25 @@ Something else.
self.assertEqual(cm.exception.code, 404)
def test_subject_encoding_error(self):
# GL#383: messages with badly encoded Subject headers crash the REST
# server.
self._msg = mfs("""\
From: [email protected]
To: [email protected]
Subject: =?GB2312?B?saa9o7fmtNPEpbVaQ2h1o6zDt7uoz+PX1L/guq7AtKGj?=
Message-ID: <alpha>
Something else.
with transaction():
held_id = hold_message(self._mlist, self._msg)
json, response = call_api(
'http://localhost:9001/3.0/lists/[email protected]/held')
self.assertEqual(response.status_code, 200)
self.assertEqual(json['total_size'], 1)
self.assertEqual(json['entries'][0]['request_id'], held_id)
class TestSubscriptionModeration(unittest.TestCase):
layer = RESTLayer
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment