Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: f58acb58 by Mark Sapiro at 2021-07-10T22:29:02-07:00 Ensure existing CC and reply-to are included in the dmarc wrapper. - - - - - 1d4a685c by Mark Sapiro at 2021-07-11T05:56:29+00:00 Merge branch 'wrap' into 'master' Ensure existing CC and reply-to are included in the dmarc wrapper. Closes #926 See merge request mailman/mailman!891 - - - - - 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 ===================================== @@ -88,6 +88,8 @@ Bugs * RFC 2047 encoded subject headers will now be recoded in the character set of the list's preferred_language during subject prefixing if possible. (Closes #923) +* DMARC mitigation wrap message now ensures existing cc and reply-to headers + are included in the wrapper. (Closes #926) Command line ------------ ===================================== src/mailman/handlers/dmarc.py ===================================== @@ -132,13 +132,18 @@ def munged_headers(mlist, msg, msgdata): if mlist.reply_goes_to_list is ReplyToMunging.no_munging: # Add original from to Reply-To: add_to = 'Reply-To' + other = ('Cc', msg.get('cc')) else: # Add original from to Cc: add_to = 'Cc' + other = ('Reply-To', msg.get('reply-to')) original = getaddresses(msg.get_all(add_to, [])) if original_from[1] not in [x[1] for x in original]: original.append(original_from) value.append((add_to, COMMASPACE.join(formataddr(x) for x in original))) + # Also, add the other if any. + if other[1] is not None: + value.append((other[0], other[1])) return value ===================================== src/mailman/handlers/tests/test_dmarc.py ===================================== @@ -408,6 +408,58 @@ Content-Disposition: inline """ + self._text) + def test_wrap_message_cc_with_reply_to(self): + self._mlist.dmarc_mitigate_action = DMARCMitigateAction.wrap_message + self._mlist.reply_goes_to_list = ReplyToMunging.point_to_list + msgdata = {'dmarc': True} + msg = mfs(self._text) + msg['Reply-To'] = 'u...@example.com' + orig_msg = msg.as_string() + dmarc.process(self._mlist, msg, msgdata) + # We can't predict the Message-ID in the wrapper so delete it, but + # ensure we have one. + self.assertIsNotNone(msg.get('message-id')) + del msg['message-id'] + self.assertMultiLineEqual(msg.as_string(), """\ +To: a...@example.com +Subject: A subject +X-Mailman-Version: X.Y +Date: Fri, 1 Jan 2016 00:00:01 +0000 +MIME-Version: 1.0 +From: anne--- via Ant <a...@example.com> +Cc: a...@example.com +Reply-To: u...@example.com +Content-Type: message/rfc822 +Content-Disposition: inline + +""" + orig_msg) + + def test_wrap_message_reply_to_with_cc(self): + self._mlist.dmarc_mitigate_action = DMARCMitigateAction.wrap_message + self._mlist.reply_goes_to_list = ReplyToMunging.no_munging + msgdata = {'dmarc': True} + msg = mfs(self._text) + msg['Cc'] = 'u...@example.com' + orig_msg = msg.as_string() + dmarc.process(self._mlist, msg, msgdata) + # We can't predict the Message-ID in the wrapper so delete it, but + # ensure we have one. + self.assertIsNotNone(msg.get('message-id')) + del msg['message-id'] + self.assertMultiLineEqual(msg.as_string(), """\ +To: a...@example.com +Subject: A subject +X-Mailman-Version: X.Y +Date: Fri, 1 Jan 2016 00:00:01 +0000 +MIME-Version: 1.0 +From: anne--- via Ant <a...@example.com> +Reply-To: a...@example.com +Cc: u...@example.com +Content-Type: message/rfc822 +Content-Disposition: inline + +""" + orig_msg) + def test_rfc2047_encoded_from(self): self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from msgdata = {'dmarc': True} View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/0a9d9aa67471ec39565ddeef7060846579cb7fb9...1d4a685cf6446d13f2fefd08760d5b26e8f8edbf -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/0a9d9aa67471ec39565ddeef7060846579cb7fb9...1d4a685cf6446d13f2fefd08760d5b26e8f8edbf 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