Apply 70_invalid_utf8_dos.patch
authorMichael Spang <mspang@uwaterloo.ca>
Thu, 13 Sep 2007 00:33:00 +0000 (20:33 -0400)
committerMichael Spang <mspang@uwaterloo.ca>
Thu, 13 Sep 2007 00:33:00 +0000 (20:33 -0400)
Mailman/Handlers/Scrubber.py

index ddef51f..7cd15e6 100644 (file)
@@ -302,7 +302,10 @@ Url: %(url)s
             finally:
                 os.umask(omask)
             desc = part.get('content-description', _('not available'))
-            filename = part.get_filename(_('not available'))
+            try:
+                filename = part.get_filename(_('not available'))
+            except UnicodeDecodeError:
+                filename = _('not available')
             filename = Utils.oneline(filename, lcset)
             replace_payload_by_text(part, _("""\
 A non-text attachment was scrubbed...
@@ -412,7 +415,10 @@ def save_attachment(mlist, msg, dir, filter_html=True):
     ctype = msg.get_content_type()
     # i18n file name is encoded
     lcset = Utils.GetCharSet(mlist.preferred_language)
-    filename = Utils.oneline(msg.get_filename(''), lcset)
+    try:
+        filename = Utils.oneline(msg.get_filename(''), lcset)
+    except UnicodeDecodeError:
+        filename = ''
     fnext = os.path.splitext(filename)[1]
     # For safety, we should confirm this is valid ext for content-type
     # but we can use fnext if we introduce fnext filtering
@@ -438,7 +444,10 @@ def save_attachment(mlist, msg, dir, filter_html=True):
     try:
         # Now base the filename on what's in the attachment, uniquifying it if
         # necessary.
-        filename = msg.get_filename()
+        try:
+            filename = msg.get_filename()
+        except UnicodeDecodeError:
+            filename = None
         if not filename or mm_cfg.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME:
             filebase = 'attachment'
         else: