Revision: 8232
          http://svn.sourceforge.net/mailman/?rev=8232&view=rev
Author:   msapiro
Date:     2007-06-09 12:30:36 -0700 (Sat, 09 Jun 2007)

Log Message:
-----------
Improved processing of an Approve(d): body line by decoding the body payload
before looking for/deleting the Approve(d): line.

Modified Paths:
--------------
    branches/Release_2_1-maint/mailman/Mailman/Handlers/Approve.py
    branches/Release_2_1-maint/mailman/NEWS

Modified: branches/Release_2_1-maint/mailman/Mailman/Handlers/Approve.py
===================================================================
--- branches/Release_2_1-maint/mailman/Mailman/Handlers/Approve.py      
2007-06-02 02:06:53 UTC (rev 8231)
+++ branches/Release_2_1-maint/mailman/Mailman/Handlers/Approve.py      
2007-06-09 19:30:36 UTC (rev 8232)
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2007 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
@@ -65,7 +65,7 @@
         # XXX I'm not entirely sure why, but it is possible for the payload of
         # the part to be None, and you can't splitlines() on None.
         if part is not None and part.get_payload() is not None:
-            lines = part.get_payload().splitlines()
+            lines = part.get_payload(decode=True).splitlines()
             line = ''
             for lineno, line in zip(range(len(lines)), lines):
                 if line.strip():
@@ -79,7 +79,7 @@
                     # Now strip the first line from the payload so the
                     # password doesn't leak.
                     del lines[lineno]
-                    part.set_payload(NL.join(lines))
+                    reset_payload(part, NL.join(lines))
                     stripped = True
         if stripped:
             # MAS: Bug 1181161 - Now try all the text parts in case it's
@@ -101,10 +101,9 @@
             pattern = name + ':(\s| )*' + re.escape(passwd)
             for part in typed_subpart_iterator(msg, 'text'):
                 if part is not None and part.get_payload() is not None:
-                    # Should we decode the payload?
-                    lines = part.get_payload()
+                    lines = part.get_payload(decode=True)
                     if re.search(pattern, lines):
-                        part.set_payload(re.sub(pattern, '', lines))
+                        reset_payload(part, re.sub(pattern, '', lines))
     if passwd is not missing and mlist.Authenticate((mm_cfg.AuthListModerator,
                                                      mm_cfg.AuthListAdmin),
                                                     passwd):
@@ -117,3 +116,20 @@
     beentheres = [s.strip().lower() for s in msg.get_all('x-beenthere', [])]
     if mlist.GetListEmail().lower() in beentheres:
         raise Errors.LoopError
+
+def reset_payload(part, payload):
+    # Set decoded payload maintaining content-type, format and delsp.
+    # TK: Message with 'charset=' cause trouble. So, instead of
+    #     part.get_content_charset('us-ascii') ...
+    cset = part.get_content_charset() or 'us-ascii'
+    ctype = part.get_content_type()
+    format = part.get_param('format')
+    delsp = part.get_param('delsp')
+    del part['content-transfer-encoding']
+    del part['content-type']
+    part.set_payload(payload, cset)
+    part.set_type(ctype)
+    if format:
+        part.set_param('Format', format)
+    if delsp:
+        part.set_param('DelSp', delsp)

Modified: branches/Release_2_1-maint/mailman/NEWS
===================================================================
--- branches/Release_2_1-maint/mailman/NEWS     2007-06-02 02:06:53 UTC (rev 
8231)
+++ branches/Release_2_1-maint/mailman/NEWS     2007-06-09 19:30:36 UTC (rev 
8232)
@@ -42,6 +42,10 @@
       changes to scripts that screen-scrape the web admin interface to
       produce a membership list so they will report an unquoted address.
 
+    - The fix for bug 1181161 in 2.1.7 was incomplete.  The Approve(d): line
+      wasn't always found in quoted-printable encoded parts and was never
+      found in base64 encoded parts.  This is now fixed.
+
 2.1.9 (12-Sep-2006)
 
   Security


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to