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


Commits:
54f33813 by Mark Sapiro at 2022-03-18T19:28:37-07:00
Check for a nonmember display name when munging From:

- - - - -
1c4c4b4c by Mark Sapiro at 2022-03-19T02:53:17+00:00
Merge branch 'munge' into 'master'

Check for a nonmember display name when munging From:

See merge request mailman/mailman!990
- - - - -


3 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/handlers/dmarc.py
- src/mailman/handlers/tests/test_dmarc.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -50,6 +50,8 @@ Bugs fixed
   The various mailman.po files have been updated accordingly.  (Closes #987)
 * The ``mailman import21`` command no longer creates unnecessary entries in the
   ``template`` table.  (Closes #988)
+* DMARC munge from mitigation will now find a nonmember poster's display name.
+  (Closes #989)
 
 REST
 ====


=====================================
src/mailman/handlers/dmarc.py
=====================================
@@ -99,7 +99,8 @@ def munged_headers(mlist, msg, msgdata):
     # If there was no display name in the email header, see if we have a
     # matching member with a display name.
     if len(realname) == 0:
-        member = mlist.members.get_member(email)
+        member = (mlist.members.get_member(email) or
+                  mlist.nonmembers.get_member(email))
         if member:
             realname = member.display_name or email
         else:


=====================================
src/mailman/handlers/tests/test_dmarc.py
=====================================
@@ -23,6 +23,7 @@ from mailman.app.lifecycle import create_list
 from mailman.app.membership import add_member
 from mailman.handlers import dmarc
 from mailman.interfaces.mailinglist import DMARCMitigateAction, ReplyToMunging
+from mailman.interfaces.member import MemberRole
 from mailman.interfaces.subscriptions import RequestRecord
 from mailman.testing.helpers import specialized_message_from_string as mfs
 from mailman.testing.layers import ConfigLayer
@@ -270,6 +271,41 @@ Some things to say.
 Content-Type: text/html; charset="us-ascii"
 Content-Transfer-Encoding: 7bit
 
+<html><head></head><body>Some things to say.</body></html>
+--=====abc==--
+""")
+
+    def test_action_munge_from_nonmember_display_name_in_list(self):
+        self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from
+        add_member(
+            self._mlist,
+            RequestRecord('a...@example.com', 'Anna Banana'),
+            role=MemberRole.nonmember
+            )
+        msgdata = {'dmarc': True}
+        msg = mfs(self._text)
+        dmarc.process(self._mlist, msg, msgdata)
+        self.assertMultiLineEqual(msg.as_string(), """\
+To: a...@example.com
+Subject: A subject
+X-Mailman-Version: X.Y
+Message-ID: <al...@example.com>
+Date: Fri, 1 Jan 2016 00:00:01 +0000
+Another-Header: To test removal in wrapper
+MIME-Version: 1.0
+Content-Type: multipart/alternative; boundary="=====abc=="
+From: Anna Banana via Ant <a...@example.com>
+Reply-To: a...@example.com
+
+--=====abc==
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+Some things to say.
+--=====abc==
+Content-Type: text/html; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
 <html><head></head><body>Some things to say.</body></html>
 --=====abc==--
 """)



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/000c56e42ec4d5e1da6e8174de41031a3d2ad387...1c4c4b4c0c936976c06da883c4b61d3b6ea2d9aa

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/000c56e42ec4d5e1da6e8174de41031a3d2ad387...1c4c4b4c0c936976c06da883c4b61d3b6ea2d9aa
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