diff roundup/mailgw.py @ 1410:3a853f1c20b5 maint-0.5

backporting fixes from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Thu, 06 Feb 2003 05:44:49 +0000
parents 83f33642d220
children 5a2a89a2f4aa
line wrap: on
line diff
--- a/roundup/mailgw.py	Fri Jan 24 06:42:32 2003 +0000
+++ b/roundup/mailgw.py	Thu Feb 06 05:44:49 2003 +0000
@@ -73,12 +73,12 @@
 an exception, the original message is bounced back to the sender with the
 explanatory message given in the exception. 
 
-$Id: mailgw.py,v 1.104 2003-01-06 21:28:38 richard Exp $
+$Id: mailgw.py,v 1.104.2.1 2003-02-06 05:44:49 richard Exp $
 '''
 
 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
 import time, random, sys
-import traceback, MimeWriter
+import traceback, MimeWriter, rfc822
 import hyperdb, date, password
 
 SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '')
@@ -111,6 +111,26 @@
         description="User may use the email interface")
     security.addPermissionToRole('Admin', p)
 
+def getparam(str, param):
+    ''' From the rfc822 "header" string, extract "param" if it appears.
+    '''
+    if ';' not in str:
+        return None
+    str = str[str.index(';'):]
+    while str[:1] == ';':
+        str = str[1:]
+        if ';' in str:
+            # XXX Should parse quotes!
+            end = str.index(';')
+        else:
+            end = len(str)
+        f = str[:end]
+        if '=' in f:
+            i = f.index('=')
+            if f[:i].strip().lower() == param:
+                return rfc822.unquote(f[i+1:].strip())
+    return None
+
 class Message(mimetools.Message):
     ''' subclass mimetools.Message so we can retrieve the parts of the
         message...
@@ -662,7 +682,7 @@
                     props[propname] = value.lower() in ('yes', 'true', 'on', '1')
                 elif isinstance(proptype, hyperdb.Number):
                     value = value.strip()
-                    props[propname] = int(value)
+                    props[propname] = float(value)
 
             # handle any errors parsing the argument list
             if errors:
@@ -757,7 +777,7 @@
                     if not name:
                         disp = part.getheader('content-disposition', None)
                         if disp:
-                            name = disp.getparam('filename')
+                            name = getparam(disp, 'filename')
                             if name:
                                 name = name.strip()
                     # this is just an attachment

Roundup Issue Tracker: http://roundup-tracker.org/