Barry Warsaw pushed to branch release-3.0 at mailman / Mailman

Commits:
401a3e10 by Aurélien Bompard at 2015-11-29T11:11:41Z
Allow list names to have command suffixes

Fixes #168

- - - - -


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
@@ -18,6 +18,8 @@ Bugs
    addresses. Given by Aurélien Bompard.
  * Fix traceback in approved handler when the moderator password is None.
    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)
 
 REST
 ----


=====================================
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/401a3e10798b20015d0d5fcdb428061e6bd3fca0
_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to