diff options
| author | Mark Sapiro | 2017-06-13 09:32:12 -0700 |
|---|---|---|
| committer | Mark Sapiro | 2017-06-13 09:32:12 -0700 |
| commit | 522c0a73d70cb1aa76881376705c7384759580a9 (patch) | |
| tree | d1dcbee6690c1ce00c749f9c5c6b87b77d6557c0 /src | |
| parent | ccde15919fe89cd47d9f57d79d3450eb85253fcb (diff) | |
| download | mailman-522c0a73d70cb1aa76881376705c7384759580a9.tar.gz mailman-522c0a73d70cb1aa76881376705c7384759580a9.tar.zst mailman-522c0a73d70cb1aa76881376705c7384759580a9.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/docs/NEWS.rst | 6 | ||||
| -rw-r--r-- | src/mailman/handlers/mime_delete.py | 5 | ||||
| -rw-r--r-- | src/mailman/handlers/tests/test_mimedel.py | 25 |
3 files changed, 35 insertions, 1 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index 2bc2335f3..df8032284 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -12,6 +12,12 @@ Here is a history of user visible changes to Mailman. ============================== (201X-XX-XX) +Bugs +---- + * A missing html_to_plain_text_command is now properly detected and logged. + (closes #345) + + 3.1.0 -- "Between The Wheels" ============================= (2017-05-25) diff --git a/src/mailman/handlers/mime_delete.py b/src/mailman/handlers/mime_delete.py index 14aee1a0e..4f1b08ac7 100644 --- a/src/mailman/handlers/mime_delete.py +++ b/src/mailman/handlers/mime_delete.py @@ -279,7 +279,10 @@ def to_plaintext(msg): try: stdout = subprocess.check_output( command, universal_newlines=True) - except subprocess.CalledProcessError: + except (FileNotFoundError, + PermissionError, + subprocess.CalledProcessError, + ): log.exception('HTML -> text/plain command error') else: # Replace the payload of the subpart with the converted text diff --git a/src/mailman/handlers/tests/test_mimedel.py b/src/mailman/handlers/tests/test_mimedel.py index 3a50852da..40ebd4439 100644 --- a/src/mailman/handlers/tests/test_mimedel.py +++ b/src/mailman/handlers/tests/test_mimedel.py @@ -220,6 +220,31 @@ MIME-Version: 1.0 payload_lines = msg.get_payload().splitlines() self.assertEqual(payload_lines[0], 'Converted text/html to text/plain') + def test_missing_html_to_plain_text_command(self): + # Calling a missing html_to_plain_text_command is properly logged. + msg = mfs("""\ +From: aperson@example.com +Content-Type: text/html +MIME-Version: 1.0 + +<html><head></head> +<body></body></html> +""") + process = config.handlers['mime-delete'].process + config.push('html_filter', """\ +[mailman] +html_to_plain_text_command = /non/existent/path/to/bogus/command $filename +""") + self.addCleanup(config.pop, 'html_filter') + mark = LogFileMark('mailman.error') + process(self._mlist, msg, {}) + line = mark.readline()[:-1] + self.assertTrue(line.endswith('HTML -> text/plain command error')) + self.assertEqual(msg.get_content_type(), 'text/html') + self.assertIsNone(msg['x-content-filtered-by']) + payload_lines = msg.get_payload().splitlines() + self.assertEqual(payload_lines[0], '<html><head></head>') + class TestMiscellaneous(unittest.TestCase): """Test various miscellaneous filtering actions.""" |
