Skip to content

Commit 3cfb67a

Browse files
author
Engelbert Gruber
committed
mailgw checks encoding on first part too.
1 parent 71fbe87 commit 3cfb67a

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Feature:
1010
. you can now use the roundup-admin tool pack the database
1111

1212
Fixed:
13+
. mailgw checks encoding on first part too.
1314
. the mail gateway now responds with an error message when invalid values
1415
for arguments are specified for link or mutlilink properties
1516
. modified unit test to check nosy and assignedto when specified as arguments
@@ -26,7 +27,6 @@ Fixed:
2627
. run_tests testReldate_date failed if LANG is 'german'
2728
. mailgw failures (unexpected ones) are forwarded to the roundup admin
2829

29-
3030
2002-01-16 - 0.4.0b2
3131
Fixed:
3232
. #495392 ] empty nosy -patch

roundup/mailgw.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373
an exception, the original message is bounced back to the sender with the
7474
explanatory 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, '''
522540
Roundup 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

Comments
 (0)