diff options
| author | Aurélien Bompard | 2015-11-25 14:20:27 +0100 |
|---|---|---|
| committer | Barry Warsaw | 2015-11-29 11:40:15 -0500 |
| commit | 015a498f735cfc3a90ae07bd178ebb1c6f4bf8e0 (patch) | |
| tree | d3c8e6953c7f118acffb06d3f9285c944768f1b6 | |
| parent | 8413ae86bfce8665fc94a8e3fb8b5e0624a46f25 (diff) | |
| download | mailman-015a498f735cfc3a90ae07bd178ebb1c6f4bf8e0.tar.gz mailman-015a498f735cfc3a90ae07bd178ebb1c6f4bf8e0.tar.zst mailman-015a498f735cfc3a90ae07bd178ebb1c6f4bf8e0.zip | |
| -rw-r--r-- | src/mailman/docs/NEWS.rst | 6 | ||||
| -rw-r--r-- | src/mailman/runners/lmtp.py | 6 | ||||
| -rw-r--r-- | src/mailman/runners/tests/test_lmtp.py | 32 |
3 files changed, 42 insertions, 2 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index b92b17773..e2f81c4b4 100644 --- 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 ------------- diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py index bd577803e..be6fb81f9 100644 --- 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) diff --git a/src/mailman/runners/tests/test_lmtp.py b/src/mailman/runners/tests/test_lmtp.py index 1a6112e3c..f16350786 100644 --- 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-join@example.com') + self._lmtp.sendmail('anne@example.com', ['test-join@example.com'], """\ +From: anne@example.com +To: test-join@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-join@example.com') + self._lmtp.sendmail('anne@example.com', + ['test-join-join@example.com'], """\ +From: anne@example.com +To: test-join-join@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): |
