Mark Sapiro wrote:

>Xueshan Feng wrote:
>>
>>The digest error messages are two types:
>>
>>
>>1. Traceback (most recent call last):
>>  File "./senddigests", line 95, in ?
>>    main()
>>  File "./senddigests", line 87, in main
>>    mlist.send_digest_now()
>>  File "/var/lib/mailman/Mailman/Digester.py", line 60, in
>>send_digest_now
>>    ToDigest.send_digests(self, mboxfp)
>>  File "/var/lib/mailman/Mailman/Handlers/ToDigest.py", line 142, in
>>send_digest
>>s
>>    send_i18n_digests(mlist, mboxfp)
>>  File "/var/lib/mailman/Mailman/Handlers/ToDigest.py", line 324, in
>>send_i18n_d
>>igests
>>    msg = scrubber(mlist, msg)
>>  File "/var/lib/mailman/Mailman/Handlers/Scrubber.py", line 372, in
>>process
>>    t = unicode(t, partcharset, 'replace')
>>TypeError: coercing to Unicode: need string or buffer, NoneType found
>
>
>Possibly a message with an empty sub-part. This is something we should
>check in Scrubber.


Actually, it turns out that this was a delivery status notification
returned to the list. The Python email package handles
message/delivery-status parts in a speial way which results in part
payloads of None.


>>2.Traceback (most recent call last):
>>  File "./senddigests", line 95, in ?
>>    main()
>>  File "./senddigests", line 87, in main
>>    mlist.send_digest_now()
>>  File "/var/lib/mailman/Mailman/Digester.py", line 60, in
>>send_digest_now
>>    ToDigest.send_digests(self, mboxfp)
>>  File "/var/lib/mailman/Mailman/Handlers/ToDigest.py", line 142, in
>>send_digests
>>    send_i18n_digests(mlist, mboxfp)
>>  File "/var/lib/mailman/Mailman/Handlers/ToDigest.py", line 324, in
>>send_i18n_digests
>>    msg = scrubber(mlist, msg)
>>  File "/var/lib/mailman/Mailman/Handlers/Scrubber.py", line 306, in
>>process
>>    url = save_attachment(mlist, part, dir)
>>  File "/var/lib/mailman/Mailman/Handlers/Scrubber.py", line 483, in
>>save_attachment
>>    if os.path.exists(path):
>>  File "/usr/lib/python2.3/posixpath.py", line 174, in exists
>>    st = os.stat(path)
>>TypeError: stat() argument 1 must be (encoded string without NULL
>>bytes), not str


And this was a message with an improprly encoded RFC 2047 filename
parameter which had a trailing null byte.

Both of these issues are fixed by the attached Scrubber.patch.txt patch
to Mailman/Handlers/Scrubber.py.

-- 
Mark Sapiro <[EMAIL PROTECTED]>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

Index: Scrubber.py
===================================================================
--- Scrubber.py (revision 8236)
+++ Scrubber.py (working copy)
@@ -373,7 +373,9 @@
                 partcharset = str(partcharset)
             else:
                 partcharset = part.get_content_charset()
-            if partcharset and partcharset <> charset:
+            # If the part is Content-Type: message/delivery-status, payload is
+            # None so test here.
+            if t and partcharset and partcharset <> charset:
                 try:
                     t = unicode(t, partcharset, 'replace')
                 except (UnicodeError, LookupError, ValueError, AssertionError):
@@ -436,7 +438,7 @@
     # i18n file name is encoded
     lcset = Utils.GetCharSet(mlist.preferred_language)
     filename = Utils.oneline(msg.get_filename(''), lcset)
-    fnext = os.path.splitext(filename)[1]
+    filename, fnext = os.path.splitext(filename)
     # For safety, we should confirm this is valid ext for content-type
     # but we can use fnext if we introduce fnext filtering
     if mm_cfg.SCRUBBER_USE_ATTACHMENT_FILENAME_EXTENSION:
@@ -444,6 +446,8 @@
         ext = fnext or guess_extension(ctype, fnext)
     else:
         ext = guess_extension(ctype, fnext)
+    # Allow only alphanumerics, dash, underscore, and dot
+    ext = sre.sub('', ext)
     if not ext:
         # We don't know what it is, so assume it's just a shapeless
         # application/octet-stream, unless the Content-Type: is
@@ -461,7 +465,6 @@
     try:
         # Now base the filename on what's in the attachment, uniquifying it if
         # necessary.
-        filename = msg.get_filename()
         if not filename or mm_cfg.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME:
             filebase = 'attachment'
         else:
------------------------------------------------------
Mailman-Users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Security Policy: 
http://www.python.org/cgi-bin/faqw-mm.py?req=show&amp;file=faq01.027.htp

Reply via email to