Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: d52586c3 by Mark Sapiro at 2021-06-14T17:53:48-07:00 Catch UnicodeDecodeError when decoding RFC 2047 encoded subject. - - - - - 79e7d618 by Mark Sapiro at 2021-06-15T01:21:35+00:00 Merge branch 'notify' into 'master' Catch UnicodeDecodeError when decoding RFC 2047 encoded subject. See merge request mailman/mailman!875 - - - - - 3 changed files: - src/mailman/commands/cli_notify.py - src/mailman/commands/tests/test_cli_notify.py - src/mailman/docs/NEWS.rst Changes: ===================================== src/mailman/commands/cli_notify.py ===================================== @@ -122,8 +122,11 @@ def _build_detail(requestdb, subs, unsubs): subject = data['_mod_subject'] reason = data['_mod_reason'] detail += ' ' + _('Sender: {}\n').format(sender) - detail += ' ' + _('Subject: {}\n').format( - str(make_header(decode_header(subject)))) + try: + detail += ' ' + _('Subject: {}\n').format( + str(make_header(decode_header(subject)))) + except UnicodeDecodeError: + detail += ' ' + _('Subject: {}\n').format(subject) detail += ' ' + _('Reason: {}\n\n').format(reason) else: detail += ' ' + _( # pragma: nocover ===================================== src/mailman/commands/tests/test_cli_notify.py ===================================== @@ -161,3 +161,40 @@ Held Messages: Please attend to this at your earliest convenience. """) + + +class TestBogusRFC2047(unittest.TestCase): + layer = ConfigLayer + + def setUp(self): + self._mlist = create_list('a...@example.com') + msg = mfs("""\ +To: a...@example.com +From: a...@example.com +Subject: =?gb2312?q?=E9=FF_message_1?= + +""") + # Hold this message. + hold_message(self._mlist, msg, {}, 'Non-member post') + self._command = CliRunner() + + def test_bogus_rfc2047(self): + # Clear messages from setup. + get_queue_messages('virgin') + result = self._command.invoke(notify, ('-v',)) + self.assertMultiLineEqual(result.output, """\ +The a...@example.com list has 1 moderation requests waiting. +""") + msg = get_queue_messages('virgin', expected_count=1)[0].msg + self.assertMultiLineEqual(msg.get_payload(), """\ +The a...@example.com list has 1 moderation requests waiting. + + +Held Messages: + Sender: a...@example.com + Subject: =?gb2312?q?=E9=FF_message_1?= + Reason: Non-member post + + +Please attend to this at your earliest convenience. +""") ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -80,6 +80,8 @@ Command line ------------ * The ``notify`` subcommand is now more tolerant of certain database anomalies. (Closes #861) +* The ``notify`` subcommand now handles unicode errors in decoding RFC 2047 + encoded subject headers. (Closes #915) REST ---- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/f8760c92b8ed4162bda1629d68edc774eb188303...79e7d618aeb9d7866795ad9c1cc0a25a0fdc0d22 -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/f8760c92b8ed4162bda1629d68edc774eb188303...79e7d618aeb9d7866795ad9c1cc0a25a0fdc0d22 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