Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: c4b32ed5 by Mark Sapiro at 2020-12-14T12:26:09-08:00 RFC 2047 decode From: in mail to -join. - - - - - 51131e37 by Mark Sapiro at 2020-12-14T20:49:26+00:00 Merge branch 'join' into 'master' RFC 2047 decode From: in mail to -join. Closes #802 See merge request mailman/mailman!745 - - - - - 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 ===================================== @@ -17,6 +17,7 @@ """The email commands 'join' and 'subscribe'.""" +from email.header import decode_header, make_header from email.utils import formataddr, parseaddr from mailman.core.i18n import _ from mailman.interfaces.address import InvalidEmailAddressError @@ -79,7 +80,12 @@ other than the sender of the command. if delivery_mode is ContinueProcessing.no: return ContinueProcessing.no if not address: - display_name, email = parseaddr(msg['from']) + # RFC 2047 decode the From: header. + if msg['from'] is None: + display_name, email = ('', '') + else: + decoded_from = str(make_header(decode_header(msg['from']))) + display_name, email = parseaddr(decoded_from) else: display_name, email = ('', address) # Address could be None or the empty string. ===================================== src/mailman/commands/tests/test_eml_membership.py ===================================== @@ -24,6 +24,7 @@ from mailman.commands.eml_membership import Join, Leave from mailman.email.message import Message from mailman.interfaces.bans import IBanManager from mailman.interfaces.mailinglist import SubscriptionPolicy +from mailman.interfaces.pending import IPendings from mailman.interfaces.subscriptions import ISubscriptionManager from mailman.interfaces.usermanager import IUserManager from mailman.runners.command import Results @@ -72,6 +73,24 @@ class TestJoin(unittest.TestCase): self.assertIn('Confirmation email sent to a...@example.com', str(results)) + def test_join_rfc2047_display(self): + # Subscribe a member with RFC 2047 encoded display name via join. + msg = Message() + msg['From'] = '=?utf-8?q?Anne?= <a...@example.com>' + results = Results() + self._command.process(self._mlist, msg, {}, (), results) + self.assertIn('Confirmation email sent to Anne <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('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 ===================================== @@ -28,6 +28,8 @@ Bugs * Fixed an issue where content filtering can throw UnicodeEncodeError when converting HTML to plain text. (Closes #798) * A bounce for a non-existent list is now handled. (Closes #799) +* RFC 2047 From: headers in emailed ``join`` commands are now decoded. + (Closes #802) New Features ------------ View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/99942b84d54d467324ad1409eeb9b665b772869c...51131e376de6c6c14ad64dc0713f485c2b28f0f6 -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/99942b84d54d467324ad1409eeb9b665b772869c...51131e376de6c6c14ad64dc0713f485c2b28f0f6 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