[Mailman-Users] A scrubber issue

Mark Sapiro msapiro at value.net
Sat Dec 9 20:30:28 CET 2006


Todd Zullinger wrote:
>
>--- Scrubber.py~        2006-10-01 16:28:57.000000000 -0400
>+++ Scrubber.py 2006-12-09 11:41:25.000000000 -0500
>@@ -334,7 +334,12 @@
>         text = []
>         for part in msg.walk():
>             # TK: bug-id 1099138 and multipart
>-            if not part or part.is_multipart():
>+            if not part:
>+                try:
>+                    part.as_string()
>+                except:
>+                    continue
>+            elif part.is_multipart():
>                 continue
>             # All parts should be scrubbed to text/plain by now.
>             partctype = part.get_content_type()


In another reply, I suggested a simpler change

--- Scrubber.py~        2006-10-01 16:28:57.000000000 -0400
+++ Scrubber.py 2006-12-09 11:41:25.000000000 -0500
@@ -334,7 +334,7 @@
         text = []
         for part in msg.walk():
             # TK: bug-id 1099138 and multipart
-            if not part or part.is_multipart():
+            if not part.get_payload() or part.is_multipart():
                 continue
             # All parts should be scrubbed to text/plain by now.
             partctype = part.get_content_type()

but I'm not sure. This will discard a part with an 'empty' payload as
well as a part with payload = None. The argument for doing this is no
real harm is done by discarding this 'empty' payload, and we probably
don't want to replace it with a link in any case which might happen if
we leave it.

In order to fix the bug we really only need to skip parts with payload
= None so if we want to keep the 'empty' part, the fix should be

--- Scrubber.py~        2006-10-01 16:28:57.000000000 -0400
+++ Scrubber.py 2006-12-09 11:41:25.000000000 -0500
@@ -334,7 +334,7 @@
         text = []
         for part in msg.walk():
             # TK: bug-id 1099138 and multipart
-            if not part or part.is_multipart():
+            if part.get_payload() == None or part.is_multipart():
                 continue
             # All parts should be scrubbed to text/plain by now.
             partctype = part.get_content_type()

-- 
Mark Sapiro <msapiro at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Users mailing list