Barry Warsaw pushed to branch master at mailman / Mailman
Commits: 015a498f by Aurélien Bompard at 2015-11-29T11:40:15Z Allow list names to have command suffixes Fixes #168 Minor style fixes and add another test. - - - - - 3 changed files: - src/mailman/docs/NEWS.rst - src/mailman/runners/lmtp.py - src/mailman/runners/tests/test_lmtp.py Changes: ===================================== src/mailman/docs/NEWS.rst ===================================== --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -1,4 +1,4 @@ -================================================ +=============================================== Mailman - The GNU Mailing List Management System ================================================ @@ -47,7 +47,9 @@ Bugs * Fix traceback in approved handler when the moderator password is None. Given by Aurélien Bompard. * Fix IntegrityErrors raised under PostreSQL when deleting users and - addresses. Given by Aurélien Bompard. + addresses. Given by Aurélien Bompard. + * Allow mailing lists to have localhost names with a suffix matching the + subcommand extensions. Given by Aurélien Bompard. (Closes: #168) Configuration ------------- ===================================== src/mailman/runners/lmtp.py ===================================== --- a/src/mailman/runners/lmtp.py +++ b/src/mailman/runners/lmtp.py @@ -212,6 +212,12 @@ class LMTPRunner(Runner, smtpd.SMTPServer): try: to = parseaddr(to)[1].lower() local, subaddress, domain = split_recipient(to) + if subaddress is not None: + # Check that local-subaddress is not an actual list name. + listname = '{}-{}@{}'.format(local, subaddress, domain) + if listname in listnames: + local = '{}-{}'.format(local, subaddress) + subaddress = None slog.debug('%s to: %s, list: %s, sub: %s, dom: %s', message_id, to, local, subaddress, domain) listname = '{}@{}'.format(local, domain) ===================================== src/mailman/runners/tests/test_lmtp.py ===================================== --- a/src/mailman/runners/tests/test_lmtp.py +++ b/src/mailman/runners/tests/test_lmtp.py @@ -144,6 +144,38 @@ Message-ID: <aardvark> self.assertEqual(cm.exception.smtp_error, b'Requested action not taken: mailbox unavailable') + def test_mailing_list_with_subaddress(self): + # A mailing list with a subaddress in its name should be recognized as + # the mailing list, not as a command. + with transaction(): + create_list('test-j...@example.com') + self._lmtp.sendmail('a...@example.com', ['test-j...@example.com'], """\ +From: a...@example.com +To: test-j...@example.com +Message-ID: <ant> +Subject: This should not be recognized as a join command + +""") + # The message is in the incoming queue but not the command queue. + self.assertEqual(len(get_queue_messages('in')), 1) + self.assertEqual(len(get_queue_messages('command')), 0) + + def test_mailing_list_with_subaddress_command(self): + # Like above, but we can still send a command to the mailing list. + with transaction(): + create_list('test-j...@example.com') + self._lmtp.sendmail('a...@example.com', + ['test-join-j...@example.com'], """\ +From: a...@example.com +To: test-join-j...@example.com +Message-ID: <ant> +Subject: This will be recognized as a join command. + +""") + # The message is in the command queue but not the incoming queue. + self.assertEqual(len(get_queue_messages('in')), 0) + self.assertEqual(len(get_queue_messages('command')), 1) + class TestBugs(unittest.TestCase): View it on GitLab: https://gitlab.com/mailman/mailman/commit/015a498f735cfc3a90ae07bd178ebb1c6f4bf8e0
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org