Commit 015a498f authored by Aurélien Bompard's avatar Aurélien Bompard Committed by Barry Warsaw

Allow list names to have command suffixes

Fixes #168

Minor style fixes and add another test.
parent 8413ae86
Pipeline #332953 passed with stage
================================================
===============================================
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
-------------
......
......@@ -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)
......
......@@ -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('[email protected]')
self._lmtp.sendmail('[email protected]', ['[email protected]'], """\
From: [email protected]
To: [email protected]
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('[email protected]')
self._lmtp.sendmail('[email protected]',
['[email protected]'], """\
From: [email protected]
To: [email protected]
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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment