~ubuntu-branches/ubuntu/hardy/mailman/hardy-updates

« back to all changes in this revision

Viewing changes to debian/patches/70_invalid_utf8_dos.patch

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 13:00:30 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030130030-hvz4ipqc82e3wbi6
Tags: 1:2.1.9-2ubuntu1
* Synchronize to Debian; remaining Ubuntu change:
  - debian/control: exim4 -> postfix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Patch: 70_invalid_utf8_dos.patch
 
2
Author: Lionel Elie Mamane <lionel@mamane.lu>
 
3
Avoid DOS if attachement filename is invalid Unicode string
 
4
Index: Mailman/Handlers/Scrubber.py
 
5
===================================================================
 
6
--- Mailman/Handlers/Scrubber.py.orig   2006-08-15 15:14:15.000000000 +0800
 
7
+++ Mailman/Handlers/Scrubber.py        2006-08-15 15:14:54.000000000 +0800
 
8
@@ -302,7 +302,10 @@
 
9
             finally:
 
10
                 os.umask(omask)
 
11
             desc = part.get('content-description', _('not available'))
 
12
-            filename = part.get_filename(_('not available'))
 
13
+            try:
 
14
+                filename = part.get_filename(_('not available'))
 
15
+            except UnicodeDecodeError:
 
16
+                filename = _('not available')
 
17
             filename = Utils.oneline(filename, lcset)
 
18
             replace_payload_by_text(part, _("""\
 
19
 A non-text attachment was scrubbed...
 
20
@@ -412,7 +415,10 @@
 
21
     ctype = msg.get_content_type()
 
22
     # i18n file name is encoded
 
23
     lcset = Utils.GetCharSet(mlist.preferred_language)
 
24
-    filename = Utils.oneline(msg.get_filename(''), lcset)
 
25
+    try:
 
26
+        filename = Utils.oneline(msg.get_filename(''), lcset)
 
27
+    except UnicodeDecodeError:
 
28
+        filename = ''
 
29
     fnext = os.path.splitext(filename)[1]
 
30
     # For safety, we should confirm this is valid ext for content-type
 
31
     # but we can use fnext if we introduce fnext filtering
 
32
@@ -438,7 +444,10 @@
 
33
     try:
 
34
         # Now base the filename on what's in the attachment, uniquifying it if
 
35
         # necessary.
 
36
-        filename = msg.get_filename()
 
37
+        try:
 
38
+            filename = msg.get_filename()
 
39
+        except UnicodeDecodeError:
 
40
+            filename = None
 
41
         if not filename or mm_cfg.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME:
 
42
             filebase = 'attachment'
 
43
         else: