@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373an exception, the original message is bounced back to the sender with the
7474explanatory message given in the exception.
7575
76- $Id: mailgw.py,v 1.59 2002-01-23 21 :43:23 richard Exp $
76+ $Id: mailgw.py,v 1.60 2002-02-01 07 :43:12 grubert Exp $
7777'''
7878
7979
@@ -487,8 +487,27 @@ def handle_message(self, message):
487487 subtype = part .gettype ()
488488 if subtype == 'text/plain' and not content :
489489 # add all text/plain parts to the message content
490+ # BUG (in code or comment) only add the first one.
490491 if content is None :
491- content = part .fp .read ()
492+ # try name on Content-Type
493+ # maybe add name to non text content ?
494+ name = part .getparam ('name' )
495+ # assume first part is the mail
496+ encoding = part .getencoding ()
497+ if encoding == 'base64' :
498+ data = binascii .a2b_base64 (part .fp .read ())
499+ elif encoding == 'quoted-printable' :
500+ # the quopri module wants to work with files
501+ decoded = cStringIO .StringIO ()
502+ quopri .decode (part .fp , decoded )
503+ data = decoded .getvalue ()
504+ elif encoding == 'uuencoded' :
505+ data = binascii .a2b_uu (part .fp .read ())
506+ attachments .append ((name , part .gettype (), data ))
507+ else :
508+ # take it as text
509+ data = part .fp .read ()
510+ content = data
492511 else :
493512 content = content + part .fp .read ()
494513
@@ -516,7 +535,6 @@ def handle_message(self, message):
516535 elif encoding == 'uuencoded' :
517536 data = binascii .a2b_uu (part .fp .read ())
518537 attachments .append ((name , part .gettype (), data ))
519-
520538 if content is None :
521539 raise MailUsageError , '''
522540Roundup requires the submission to be plain text. The message parser could
@@ -757,6 +775,9 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
757775
758776#
759777# $Log: not supported by cvs2svn $
778+ # Revision 1.59 2002/01/23 21:43:23 richard
779+ # tabnuke
780+ #
760781# Revision 1.58 2002/01/23 21:41:56 richard
761782# . mailgw failures (unexpected ones) are forwarded to the roundup admin
762783#
0 commit comments