------------------------------------------------------------
revno: 1139
committer: Mark Sapiro <[email protected]>
branch nick: 2.2
timestamp: Thu 2011-01-13 17:08:25 -0800
message:
  - Fixed a bug where content filtering could leave a multipart message or
    part with just one sub-part. These should be recast to just the sub-part.
    Bug #701558.
modified:
  Mailman/Handlers/MimeDel.py
  NEWS


--
lp:mailman/2.2
https://code.launchpad.net/~mailman-coders/mailman/2.2

Your team Mailman Checkins is subscribed to branch lp:mailman/2.2.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/2.2/+edit-subscription
=== modified file 'Mailman/Handlers/MimeDel.py'
--- Mailman/Handlers/MimeDel.py	2010-05-07 04:02:51 +0000
+++ Mailman/Handlers/MimeDel.py	2011-01-14 01:08:25 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2009 by the Free Software Foundation, Inc.
+# Copyright (C) 2002-2011 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -96,6 +96,11 @@
         if ctype == 'multipart/alternative':
             firstalt = msg.get_payload(0)
             reset_payload(msg, firstalt)
+    # Now that we've collapsed the MPA parts, go through the message
+    # and recast any multipart parts with only one sub-part as just
+    # the sub-part.
+    if msg.is_multipart():
+        recast_multipart(msg)
     # If we removed some parts, make note of this
     changedp = 0
     if numparts <> len([subpart for subpart in msg.walk()]):
@@ -194,6 +199,21 @@
 
 
 
+def recast_multipart(msg):
+    # If we're left with a multipart message with only one sub-part, recast
+    # the message to just the sub-part.
+    if msg.is_multipart():
+        if len(msg.get_payload()) == 1:
+            reset_payload(msg, msg.get_payload(0))
+            # now that we've recast this part, check the subordinate parts
+            recast_multipart(msg)
+        else:
+            # This part's OK but check deeper.
+            for part in msg.get_payload():
+                recast_multipart(part)
+
+
+
 def to_plaintext(msg):
     changedp = 0
     for subpart in typed_subpart_iterator(msg, 'text', 'html'):

=== modified file 'NEWS'
--- NEWS	2011-01-14 00:57:05 +0000
+++ NEWS	2011-01-14 01:08:25 +0000
@@ -83,6 +83,10 @@
 
   Bug Fixes and other patches
 
+    - Fixed a bug where content filtering could leave a multipart message or
+      part with just one sub-part. These should be recast to just the sub-part.
+      Bug #701558.
+
     - Fixed a bug that could erroneously handle posts from addresses in
       *_these_nonmembers and send held/rejected notices to bogus addresses when
       The From or other sender header is RFC 2047 encoded.  Bug #702516.

_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to