[Erp5-report] r24259 - /erp5/trunk/products/ERP5/Tool/NotificationTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Oct 20 19:46:27 CEST 2008


Author: jm
Date: Mon Oct 20 19:46:25 2008
New Revision: 24259

URL: http://svn.erp5.org?rev=24259&view=rev
Log:
Let Python escape filenames of attachments in emails.

Modified:
    erp5/trunk/products/ERP5/Tool/NotificationTool.py

Modified: erp5/trunk/products/ERP5/Tool/NotificationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/NotificationTool.py?rev=24259&r1=24258&r2=24259&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/NotificationTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/NotificationTool.py Mon Oct 20 19:46:25 2008
@@ -135,10 +135,8 @@
   message.add_header('To', to_url)
 
   for attachment in attachment_list:
-    if attachment.has_key('name'):
-      attachment_name = attachment['name']
-    else:
-      attachment_name = ''
+    attachment_name = attachment.get('name', '')
+
     # try to guess the mime type
     if not attachment.has_key('mime_type'):
       type, encoding = guess_type( attachment_name )
@@ -164,8 +162,8 @@
         part.set_payload(attachment['content'])
         Encoders.encode_base64(part)
 
-    part.add_header('Content-Disposition',
-                    'attachment; filename=%s' % attachment_name)
+    part.add_header('Content-Disposition', 'attachment',
+                    filename=attachment_name)
     part.add_header('Content-ID', '<%s>' % \
                     ''.join(['%s' % ord(i) for i in attachment_name]))
     message.attach(part)




More information about the Erp5-report mailing list