------------------------------------------------------------
revno: 1287
committer: Mark Sapiro <[email protected]>
branch nick: 2.1
timestamp: Tue 2011-04-12 21:13:10 -0700
message:
Fixed a problem where content filtering could remove the headers from
an attached message/rfc822 part if the message in that part is
multipart/alternative and collapse_alternatives is Yes. Bug #757062.
modified:
Mailman/Handlers/MimeDel.py
NEWS
tests/test_handlers.py
--
lp:mailman/2.1
https://code.launchpad.net/~mailman-coders/mailman/2.1
Your team Mailman Checkins is subscribed to branch lp:mailman/2.1.
To unsubscribe from this branch go to
https://code.launchpad.net/~mailman-coders/mailman/2.1/+edit-subscription
=== modified file 'Mailman/Handlers/MimeDel.py'
--- Mailman/Handlers/MimeDel.py 2011-04-08 02:12:56 +0000
+++ Mailman/Handlers/MimeDel.py 2011-04-13 04:13:10 +0000
@@ -187,7 +187,14 @@
if subpart.get_content_type() == 'multipart/alternative':
try:
firstalt = subpart.get_payload(0)
- newpayload.append(firstalt)
+ if msg.get_content_type() == 'message/rfc822':
+ # This is a multipart/alternative message in a
+ # message/rfc822 part. We treat it specially so as not to
+ # lose the headers.
+ reset_payload(subpart, firstalt)
+ newpayload.append(subpart)
+ else:
+ newpayload.append(firstalt)
except (IndexError, TypeError):
pass
elif subpart.is_multipart():
=== modified file 'NEWS'
--- NEWS 2011-03-30 03:33:24 +0000
+++ NEWS 2011-04-13 04:13:10 +0000
@@ -37,6 +37,9 @@
Bug #670988.
Bug Fixes and other patches
+ - Fixed a problem where content filtering could remove the headers from
+ an attached message/rfc822 part if the message in that part is
+ multipart/alternative and collapse_alternatives is Yes. Bug #757062.
- Changed the subscribe CGI to strip leading and trailing whitespace from
the supplied email address. Bug #745432.
=== modified file 'tests/test_handlers.py'
--- tests/test_handlers.py 2011-01-26 00:48:51 +0000
+++ tests/test_handlers.py 2011-04-13 04:13:10 +0000
@@ -1363,6 +1363,258 @@
eq(part2.get_content_type(), 'text/plain')
eq(part2.get_payload(), 'second text')
+ def test_message_rfc822(self):
+ eq = self.assertEqual
+ msg = email.message_from_string("""\
+Message-ID: <[email protected]>
+Date: Thu, 07 Apr 2011 18:54:50 -0700
+From: User <[email protected]>
+MIME-Version: 1.0
+To: Someone <[email protected]>
+Subject: Message Subject
+Content-Type: multipart/mixed;
+ boundary="------------050603050603060608020908"
+
+This is a multi-part message in MIME format.
+--------------050603050603060608020908
+Content-Type: text/plain; charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+
+Plain body.
+
+--------------050603050603060608020908
+Content-Type: message/rfc822
+Content-Transfer-Encoding: 7bit
+Content-Disposition: attachment
+
+Message-ID: <[email protected]>
+Date: Thu, 07 Apr 2011 18:27:27 -0700
+From: User1 <[email protected]>
+MIME-Version: 1.0
+To: Someone1 <[email protected]>
+Content-Type: multipart/mixed; boundary="------------060107040402070208020705"
+Subject: Attached Message 1 Subject
+
+This is a multi-part message in MIME format.
+--------------060107040402070208020705
+Content-Type: text/plain; charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+
+Attached Message 1 body.
+
+--------------060107040402070208020705
+Content-Type: message/rfc822
+Content-Transfer-Encoding: 7bit
+Content-Disposition: attachment
+
+From: User2 <[email protected]>
+To: Someone2 <[email protected]>
+Subject: Attached Message 2 Subject
+Date: Thu, 7 Apr 2011 19:09:35 -0500
+Message-ID: <[email protected]>
+MIME-Version: 1.0
+Content-Type: multipart/mixed;
+ boundary="----=_NextPart_000_0066_01CBF557.56C6F370"
+
+This is a multi-part message in MIME format.
+
+------=_NextPart_000_0066_01CBF557.56C6F370
+Content-Type: text/plain;
+ charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+Attached Message 2 body.
+
+------=_NextPart_000_0066_01CBF557.56C6F370
+Content-Type: message/rfc822
+Content-Transfer-Encoding: 7bit
+Content-Disposition: attachment
+
+From: User3 <[email protected]>
+To: Someone3 <[email protected]>
+Subject: Attached Message 3 Subject
+Date: Thu, 7 Apr 2011 17:22:04 -0500
+Message-ID: <[email protected]>
+MIME-Version: 1.0
+Content-Type: multipart/alternative;
+ boundary="----=_NextPart_000_0058_01CBF557.56C48270"
+
+This is a multi-part message in MIME format.
+
+------=_NextPart_000_0058_01CBF557.56C48270
+Content-Type: text/plain;
+ charset="iso-8859-1"
+Content-Transfer-Encoding: 7bit
+
+Attached Message 3 plain body.
+
+------=_NextPart_000_0058_01CBF557.56C48270
+Content-Type: text/html;
+ charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+
+Attached Message 3 html body.
+
+------=_NextPart_000_0058_01CBF557.56C48270--
+
+------=_NextPart_000_0066_01CBF557.56C6F370
+Content-Type: message/rfc822
+Content-Transfer-Encoding: 7bit
+Content-Disposition: attachment
+
+From: User4 <[email protected]>
+To: Someone4 <[email protected]>
+Subject: Attached Message 4 Subject
+Date: Thu, 7 Apr 2011 17:24:26 -0500
+Message-ID: <19CC3BDF28CF49AD988FF43B2DBC5F1D@example>
+MIME-Version: 1.0
+Content-Type: multipart/mixed;
+ boundary="----=_NextPart_000_0060_01CBF557.56C6F370"
+
+This is a multi-part message in MIME format.
+
+------=_NextPart_000_0060_01CBF557.56C6F370
+Content-Type: multipart/alternative;
+ boundary="----=_NextPart_001_0061_01CBF557.56C6F370"
+
+------=_NextPart_001_0061_01CBF557.56C6F370
+Content-Type: text/plain;
+ charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+Attached Message 4 plain body.
+
+------=_NextPart_001_0061_01CBF557.56C6F370
+Content-Type: text/html;
+ charset="us-ascii"
+Content-Transfer-Encoding: quoted-printable
+
+Attached Message 4 html body.
+
+------=_NextPart_001_0061_01CBF557.56C6F370--
+
+------=_NextPart_000_0060_01CBF557.56C6F370
+Content-Type: message/rfc822
+Content-Transfer-Encoding: 7bit
+Content-Disposition: attachment
+
+From: User5 <[email protected]>
+To: Someone5 <[email protected]>
+Subject: Attached Message 5 Subject
+Date: Thu, 7 Apr 2011 16:24:26 -0500
+Message-ID: <some_id@example>
+Content-Type: multipart/alternative;
+ boundary="----=_NextPart_000_005C_01CBF557.56C6F370"
+
+This is a multi-part message in MIME format.
+
+------=_NextPart_000_005C_01CBF557.56C6F370
+Content-Type: text/plain;
+ charset="iso-8859-1"
+Content-Transfer-Encoding: 7bit
+
+Attached Message 5 plain body.
+
+------=_NextPart_000_005C_01CBF557.56C6F370
+Content-Type: text/html;
+ charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+Attached Message 5 html body.
+
+------=_NextPart_000_005C_01CBF557.56C6F370--
+
+------=_NextPart_000_0060_01CBF557.56C6F370
+Content-Type: text/plain;
+ name="ATT00055.txt"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment;
+ filename="ATT00055.txt"
+
+Another plain part.
+
+------=_NextPart_000_0060_01CBF557.56C6F370--
+
+------=_NextPart_000_0066_01CBF557.56C6F370--
+
+--------------060107040402070208020705
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Disposition: inline
+
+Final plain part.
+
+--------------060107040402070208020705--
+
+--------------050603050603060608020908--
+""")
+ MimeDel.process(self._mlist, msg, {})
+ payload = msg.get_payload()
+ eq(len(payload), 2)
+ part1 = msg.get_payload(0)
+ eq(part1.get_content_type(), 'text/plain')
+ eq(part1.get_payload(), 'Plain body.\n')
+ part2 = msg.get_payload(1)
+ eq(part2.get_content_type(), 'message/rfc822')
+ payload = part2.get_payload()
+ eq(len(payload), 1)
+ part1 = part2.get_payload(0)
+ eq(part1['subject'], 'Attached Message 1 Subject')
+ eq(part1.get_content_type(), 'multipart/mixed')
+ payload = part1.get_payload()
+ eq(len(payload), 3)
+ part3 = part1.get_payload(2)
+ eq(part3.get_content_type(), 'text/plain')
+ eq(part3.get_payload(), 'Final plain part.\n')
+ part2 = part1.get_payload(1)
+ eq(part2.get_content_type(), 'message/rfc822')
+ part1 = part1.get_payload(0)
+ eq(part1.get_content_type(), 'text/plain')
+ eq(part1.get_payload(), 'Attached Message 1 body.\n')
+ payload = part2.get_payload()
+ eq(len(payload), 1)
+ part1 = part2.get_payload(0)
+ eq(part1['subject'], 'Attached Message 2 Subject')
+ eq(part1.get_content_type(), 'multipart/mixed')
+ payload = part1.get_payload()
+ eq(len(payload), 3)
+ part3 = part1.get_payload(2)
+ eq(part3.get_content_type(), 'message/rfc822')
+ part2 = part1.get_payload(1)
+ eq(part2.get_content_type(), 'message/rfc822')
+ part1 = part1.get_payload(0)
+ eq(part1.get_content_type(), 'text/plain')
+ eq(part1.get_payload(), 'Attached Message 2 body.\n')
+ payload = part2.get_payload()
+ eq(len(payload), 1)
+ part1 = part2.get_payload(0)
+ eq(part1['subject'], 'Attached Message 3 Subject')
+ eq(part1.get_content_type(), 'text/plain')
+ eq(part1.get_payload(), 'Attached Message 3 plain body.\n')
+ payload = part3.get_payload()
+ eq(len(payload), 1)
+ part1 = part3.get_payload(0)
+ eq(part1['subject'], 'Attached Message 4 Subject')
+ eq(part1.get_content_type(), 'multipart/mixed')
+ payload = part1.get_payload()
+ eq(len(payload), 3)
+ part3 = part1.get_payload(2)
+ eq(part3.get_content_type(), 'text/plain')
+ eq(part3.get_filename(), 'ATT00055.txt')
+ eq(part3.get_payload(), 'Another plain part.\n')
+ part2 = part1.get_payload(1)
+ eq(part2.get_content_type(), 'message/rfc822')
+ part1 = part1.get_payload(0)
+ eq(part1.get_content_type(), 'text/plain')
+ eq(part1.get_payload(), 'Attached Message 4 plain body.\n')
+ payload = part2.get_payload()
+ eq(len(payload), 1)
+ part1 = part2.get_payload(0)
+ eq(part1['subject'], 'Attached Message 5 Subject')
+ eq(part1.get_content_type(), 'text/plain')
+ eq(part1.get_payload(), 'Attached Message 5 plain body.\n')
class TestModerate(TestBase):
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org