Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
09545aa7 by Mark Sapiro at 2021-03-16T13:06:16-07:00
Don't log the folding from folded Message-ID headers in smtp.log.

- - - - -
58654b31 by Mark Sapiro at 2021-03-16T20:32:26+00:00
Merge branch 'smtplog' into 'master'

Don't log the folding from folded Message-ID headers in smtp.log.

Closes #844

See merge request mailman/mailman!798
- - - - -


4 changed files:

- setup.py
- src/mailman/docs/NEWS.rst
- src/mailman/mta/deliver.py
- src/mailman/mta/tests/test_delivery.py


Changes:

=====================================
setup.py
=====================================
@@ -127,7 +127,7 @@ case second 'm'.  Any other spelling is incorrect.""",
         'python-dateutil>=2.0',
         'passlib',
         'requests',
-        'sqlalchemy>=1.2.3',
+        'sqlalchemy>=1.2.3,<1.4',
         'zope.component',
         'zope.configuration',
         'zope.event',


=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -21,6 +21,8 @@ Bugs
   in the lmtp runner.  (Closes #836)
 * The email join command now honors the digest=<no|mime|plain> option.
   (Closes #19)
+* Folded ``Message-ID`` headers no longer cause folded smtp.log messages.
+  (Closes #844)
 
 Command line
 ------------


=====================================
src/mailman/mta/deliver.py
=====================================
@@ -99,7 +99,8 @@ def deliver(mlist, msg, msgdata):
     if size is None:
         size = len(msg.as_string())
     substitutions = dict(
-        msgid       = msg.get('message-id', 'n/a'),   # noqa: E221,E251
+        msgid       = msg.get('message-id',           # noqa: E221,E251
+                              'n/a').strip(),
         listname    = mlist.fqdn_listname,            # noqa: E221,E251
         sender      = original_sender,                # noqa: E221,E251
         recip       = len(original_recipients),       # noqa: E221,E251


=====================================
src/mailman/mta/tests/test_delivery.py
=====================================
@@ -29,7 +29,7 @@ from mailman.interfaces.template import ITemplateManager
 from mailman.mta.bulk import BulkDelivery
 from mailman.mta.deliver import Deliver
 from mailman.testing.helpers import (
-    specialized_message_from_string as mfs, subscribe)
+    LogFileMark, specialized_message_from_string as mfs, subscribe)
 from mailman.testing.layers import ConfigLayer, SMTPLayer
 from mailman.utilities.modules import find_name
 from zope.component import getUtility
@@ -357,3 +357,32 @@ Subject: test
         # Since max_sessions_per_connection is 3, sending 4 personalized
         # messages creates 2 connections.
         self.assertEqual(SMTPLayer.smtpd.get_connection_count(), 2)
+
+
+class TestDeliveryLogging(unittest.TestCase):
+    """Test that logging doesn't split on folded Message-IDs."""
+
+    layer = SMTPLayer
+
+    def setUp(self):
+        self._mlist = create_list('t...@example.com')
+        # Make Anne a member of this mailing list.
+        self._anne = subscribe(self._mlist, 'Anne', email='a...@example.org')
+        self._msg = mfs("""\
+From: a...@example.org
+To: t...@example.com
+Subject: test
+Message-ID:
+ <am6pr09mb347488bb9a684f6a23a1d37596...@am6pr09mb34.eurprd09.prod.outlook.com>
+
+""")
+        self._deliverer = find_name(config.mta.outgoing)
+
+    def test_logging_with_folded_messageid(self):
+        # Test that folded Message-ID header doesn't fold the log messages.
+        mark = LogFileMark('mailman.smtp')
+        msgdata = dict(recipients=['a...@example.org'], tolist=True)
+        self._deliverer(self._mlist, self._msg, msgdata)
+        logs = mark.read()
+        self.assertRegex(logs, r' \(\d+\) <AM6PR09MB347488.*smtp')
+        self.assertRegex(logs, r' \(\d+\) <AM6PR09MB347488.*post')



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/b7d2493d50f5183ea8a1d9382e8fc211599e98e1...58654b3111312dfc00e646f10e1f255bd85e7ffc

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/b7d2493d50f5183ea8a1d9382e8fc211599e98e1...58654b3111312dfc00e646f10e1f255bd85e7ffc
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

Reply via email to