Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
1fed3b11 by Mark Sapiro at 2022-12-31T03:15:56+00:00
Decode RFC 2047 encoded Subject: for rejection notice.

Fixes #672

- - - - -
adf630a4 by Mark Sapiro at 2022-12-31T03:15:57+00:00
Merge branch 'rej' into 'master'

Decode RFC 2047 encoded Subject: for rejection notice.

Closes #672

See merge request mailman/mailman!1080
- - - - -


3 changed files:

- src/mailman/app/moderator.py
- src/mailman/app/tests/test_moderation.py
- src/mailman/docs/NEWS.rst


Changes:

=====================================
src/mailman/app/moderator.py
=====================================
@@ -34,7 +34,7 @@ from mailman.interfaces.pending import IPendings
 from mailman.interfaces.requests import IListRequests, RequestType
 from mailman.interfaces.template import ITemplateLoader
 from mailman.utilities.datetime import now
-from mailman.utilities.string import expand, wrap
+from mailman.utilities.string import expand, oneline, wrap
 from public import public
 from zope.component import getUtility
 
@@ -114,7 +114,8 @@ def handle_message(mlist, id, action, comment=None, 
forward=None):
     rejection = None
     message_id = msgdata['_mod_message_id']
     sender = msgdata['_mod_sender']
-    subject = msgdata['_mod_subject']
+    # Decode the Subject: if necessary.
+    subject = oneline(msgdata['_mod_subject'], in_unicode=True)
     keep = False
     if action in (Action.defer, Action.hold):
         # Nothing to do, but preserve the message for later.
@@ -130,7 +131,7 @@ def handle_message(mlist, id, action, comment=None, 
forward=None):
             language = None
         send_rejection(
             mlist, _('Posting of your message titled "${subject}"'),
-            sender, comment or _('[No reason given]'), language)
+            sender, comment or _('[No reason given]'), lang=language)
     elif action is Action.accept:
         # Start by getting the message from the message store.
         msg = message_store.get_message_by_id(message_id)


=====================================
src/mailman/app/tests/test_moderation.py
=====================================
@@ -271,6 +271,21 @@ Message-ID: <alpha>
         self.assertIsNone(pendings.confirm(hash))
         self.assertIsNone(pendings.confirm(user_hash))
 
+    def test_rejection_subject_decoded(self):
+        # Test that a rejected message with an RFC 2047 encoded Subject: has
+        # the Subject: decoded for the rejection
+        del self._msg['subject']
+        self._msg['Subject'] = '=?utf-8?q?hold_me?='
+        request_id = hold_message(self._mlist, self._msg)
+        handle_message(self._mlist, request_id, Action.reject)
+        # The rejected message lives in the virgin queue.
+        items = get_queue_messages('virgin', expected_count=1)
+        rejection = items[0].msg
+        self.assertEqual(str(rejection['subject']),
+                         'Request to mailing list "Test" rejected')
+        self.assertIn('Posting of your message titled "hold me"',
+                      rejection.get_payload())
+
 
 class TestUnsubscription(unittest.TestCase):
     """Test unsubscription requests."""


=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -22,6 +22,8 @@ Bugs fixed
   the generated postfix_lmtp file.  (Closes #1044)
 * An uncaught passlib.exc.UnknownHashError in utilities/passwords.py is now
   caught and handled appropriately.  (Closes #1046)
+* Rejection notices for a message with an RFC 2047 encoded Subject: now display
+  the decoded subject.  (Closes #672)
 
 
 Command line



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/197ba91d2b4ed5e3838d4a2c4165a4ec48da458b...adf630a42fb955b9358614bd50d72a2acadaceb0

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/197ba91d2b4ed5e3838d4a2c4165a4ec48da458b...adf630a42fb955b9358614bd50d72a2acadaceb0
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

Reply via email to