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


Commits:
23588114 by Mark Sapiro at 2021-08-10T10:32:41-07:00
Parse From: in email join command before RFC2047 decoding.

- - - - -
36056099 by Mark Sapiro at 2021-08-10T18:08:21+00:00
Merge branch 'join' into 'master'

Parse From: in email join command before RFC2047 decoding.

Closes #933

See merge request mailman/mailman!901
- - - - -


3 changed files:

- src/mailman/commands/eml_membership.py
- src/mailman/commands/tests/test_eml_membership.py
- src/mailman/docs/NEWS.rst


Changes:

=====================================
src/mailman/commands/eml_membership.py
=====================================
@@ -84,8 +84,10 @@ other than the sender of the command.
             if msg['from'] is None:
                 display_name, email = ('', '')
             else:
-                decoded_from = str(make_header(decode_header(msg['from'])))
-                display_name, email = parseaddr(decoded_from)
+                # Parse before decoding in case decoded display_name contains
+                # a comma.
+                display_name, email = parseaddr(msg['from'])
+                display_name = str(make_header(decode_header(display_name)))
         else:
             display_name, email = ('', address)
         # Address could be None or the empty string.


=====================================
src/mailman/commands/tests/test_eml_membership.py
=====================================
@@ -92,6 +92,25 @@ class TestJoin(unittest.TestCase):
         self.assertEqual('Anne', pended['display_name'])
         self.assertEqual('a...@example.com', pended['email'])
 
+    def test_join_rfc2047_display_with_comma(self):
+        # Subscribe a member with RFC 2047 encoded display name containing a
+        # comma and non-ascii via join.
+        msg = Message()
+        msg['From'] = '=?utf-8?q?J=C3=BCnk=2C_Anne?= <a...@example.com>'
+        results = Results()
+        self._command.process(self._mlist, msg, {}, (), results)
+        self.assertIn('Confirmation email sent to =?utf-8?b?SsO8bmssIEFubmU=?='
+                      ' <a...@example.com>', str(results))
+        # Check the pending confirmation.
+        pendings = list(getUtility(IPendings).find(self._mlist,
+                                                   'subscription',
+                                                   confirm=False))
+        self.assertEqual(1, len(pendings))
+        token = pendings[0][0]
+        pended = getUtility(IPendings).confirm(token, expunge=False)
+        self.assertEqual('Jünk, Anne', pended['display_name'])
+        self.assertEqual('a...@example.com', pended['email'])
+
     def test_join_digest(self):
         # Subscribe a member to digest via join.
         msg = Message()


=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -98,6 +98,8 @@ Bugs
   ``SubscriptionPendingError``.  (Closes #929)
 * Trailing spaces are no longer removed from header and footer templates..
   (Closes #932)
+* The email ``join`` command now handles RFC2047 encoded display names with
+  embedded commas.  (Closes #933)
 
 Command line
 ------------



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/4721fa2724fb049b77e9da4189ca0e51cbcd7847...36056099377cda5e58ef60d6b1e5c826b141c520

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/4721fa2724fb049b77e9da4189ca0e51cbcd7847...36056099377cda5e58ef60d6b1e5c826b141c520
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