diff roundup/mailgw.py @ 1409:8dc60d87ab42

Fixed a backlog of bug reports, and worked on python 2.3 compatibility: - fixed templating filter function arguments [SF#678911] - fixed multiselect in searching [SF#676874] - fixed parsing of content-disposition filenames [SF#675116] - added 'h' to roundup-server optarg list [SF#674070] - fixed doc for db.history in anydbm and rdbms_common [SF#679221] - fixed timelog example so it handles new issues [SF#678908] - handle missing os.fork() [SF#681046] - fixed roundup-reminder [SF#681042] - fixed int assumptions about Number values [SF#677762] - added warning filter for "FutureWarning: hex/oct constants > sys.maxint will return positive values..." (literal 0xffff0000 in portalocker.py) - fixed ZPT code generating SyntaxWarning for assignment to None
author Richard Jones <richard@users.sourceforge.net>
date Thu, 06 Feb 2003 05:43:49 +0000
parents 27586da5557c
children 285934a04a6c
line wrap: on
line diff
--- a/roundup/mailgw.py	Mon Feb 03 11:14:16 2003 +0000
+++ b/roundup/mailgw.py	Thu Feb 06 05:43: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.108 2003-01-27 16:32:46 kedder Exp $
+$Id: mailgw.py,v 1.109 2003-02-06 05:43:47 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
 
 import rfc2822
@@ -113,6 +113,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...
@@ -713,6 +733,7 @@
                 elif subtype == 'multipart/alternative':
                     # Search for text/plain in message with attachment and
                     # alternative text representation
+                    # skip over intro to first boundary
                     part.getPart()
                     while 1:
                         # get the next part
@@ -730,7 +751,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
@@ -946,7 +967,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)
     return errors, props
 
 

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