Skip to content

Commit 5eaabb3

Browse files
author
Richard Jones
committed
look harder for text/plain in email
1 parent 945d6bc commit 5eaabb3

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Fixed:
99
- handle bad multilink input at item creation time better (sf bug 917834)
1010
- make sure email signature starts on a newline (sf bug 919759)
1111
- add line to rego email to help URL detection (sf bug 906247)
12+
- look harder for text/plain in email
1213

1314

1415
2004-03-01 0.6.7

roundup/mailgw.py

Lines changed: 7 additions & 30 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.126.2.2 2004-01-07 22:44:44 richard Exp $
76+
$Id: mailgw.py,v 1.126.2.3 2004-03-24 22:27:39 richard Exp $
7777
"""
7878

7979
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
@@ -765,10 +765,10 @@ def handle_message(self, message):
765765
# flagging.
766766
# multipart/form-data:
767767
# For web forms only.
768+
content = None
768769
if content_type == 'multipart/mixed':
769770
# skip over the intro to the first boundary
770771
part = message.getPart()
771-
content = None
772772
while 1:
773773
# get the next part
774774
part = message.getPart()
@@ -814,42 +814,19 @@ def handle_message(self, message):
814814
# this is just an attachment
815815
data = self.get_part_data_decoded(part)
816816
attachments.append((name, part.gettype(), data))
817-
if content is None:
818-
raise MailUsageError, '''
819-
Roundup requires the submission to be plain text. The message parser could
820-
not find a text/plain part to use.
821-
'''
822817

823-
elif content_type[:10] == 'multipart/':
824-
# skip over the intro to the first boundary
825-
message.getPart()
826-
content = None
827-
while 1:
828-
# get the next part
829-
part = message.getPart()
830-
if part is None:
831-
break
832-
# parse it
833-
if part.gettype() == 'text/plain' and not content:
834-
content = self.get_part_data_decoded(part)
835-
if content is None:
836-
raise MailUsageError, '''
837-
Roundup requires the submission to be plain text. The message parser could
838-
not find a text/plain part to use.
839-
'''
818+
elif content_type == 'text/plain':
819+
content = self.get_part_data_decoded(message)
840820

841-
elif content_type != 'text/plain':
821+
if content is None:
842822
raise MailUsageError, '''
843823
Roundup requires the submission to be plain text. The message parser could
844824
not find a text/plain part to use.
845825
'''
846-
847-
else:
848-
content = self.get_part_data_decoded(message)
849826

850827
# figure how much we should muck around with the email body
851-
keep_citations = getattr(self.instance.config, 'EMAIL_KEEP_QUOTED_TEXT',
852-
'no') == 'yes'
828+
keep_citations = getattr(self.instance.config,
829+
'EMAIL_KEEP_QUOTED_TEXT', 'no') == 'yes'
853830
keep_body = getattr(self.instance.config, 'EMAIL_LEAVE_BODY_UNCHANGED',
854831
'no') == 'yes'
855832

0 commit comments

Comments
 (0)