Skip to content

Commit 0a7f2ab

Browse files
author
Engelbert Gruber
committed
add test for multipart messages with first part being encoded.
1 parent 3cfb67a commit 0a7f2ab

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

roundup/mailgw.py

Lines changed: 6 additions & 1 deletion
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.60 2002-02-01 07:43:12 grubert Exp $
76+
$Id: mailgw.py,v 1.61 2002-02-04 09:40:21 grubert Exp $
7777
'''
7878

7979

@@ -495,6 +495,8 @@ def handle_message(self, message):
495495
# assume first part is the mail
496496
encoding = part.getencoding()
497497
if encoding == 'base64':
498+
# BUG: is base64 really used for text encoding or
499+
# are we inserting zip files here.
498500
data = binascii.a2b_base64(part.fp.read())
499501
elif encoding == 'quoted-printable':
500502
# the quopri module wants to work with files
@@ -775,6 +777,9 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
775777

776778
#
777779
# $Log: not supported by cvs2svn $
780+
# Revision 1.60 2002/02/01 07:43:12 grubert
781+
# . mailgw checks encoding on first part too.
782+
#
778783
# Revision 1.59 2002/01/23 21:43:23 richard
779784
# tabnuke
780785
#

test/test_mailgw.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_mailgw.py,v 1.7 2002-01-22 11:54:45 rochecompaan Exp $
11+
# $Id: test_mailgw.py,v 1.8 2002-02-04 09:40:21 grubert Exp $
1212

1313
import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys
1414

@@ -180,6 +180,57 @@ def testFollowup2(self):
180180
This is a second followup
181181
182182
183+
----------
184+
status: unread -> chatting
185+
___________________________________________________
186+
"Roundup issue tracker" <[email protected].>
187+
http://some.useful.url/issue1
188+
___________________________________________________
189+
''', 'Generated message not correct')
190+
191+
def testMultipartEnc01(self):
192+
self.testNewIssue()
193+
message = cStringIO.StringIO('''Content-Type: text/plain;
194+
charset="iso-8859-1"
195+
From: mary <mary@test>
196+
197+
Message-Id: <followup_dummy_id>
198+
In-Reply-To: <dummy_test_message_id>
199+
Subject: [issue1] Testing...
200+
Content-Type: multipart/mixed;
201+
boundary="----_=_NextPart_000_01"
202+
203+
This message is in MIME format. Since your mail reader does not understand
204+
this format, some or all of this message may not be legible.
205+
206+
------_=_NextPart_000_01
207+
Content-Type: text/plain;
208+
charset="iso-8859-1"
209+
Content-Transfer-Encoding: quoted-printable
210+
211+
A message with first part encoded (encoded oe =F6)
212+
213+
''')
214+
handler = self.instance.MailGW(self.instance, self.db)
215+
handler.main(message)
216+
message_data = open(os.environ['SENDMAILDEBUG']).read()
217+
self.assertEqual(message_data,
218+
219+
TO: [email protected], richard@test
220+
Content-Type: text/plain
221+
Subject: [issue1] Testing...
222+
To: [email protected], richard@test
223+
From: mary <[email protected].>
224+
Reply-To: Roundup issue tracker <[email protected].>
225+
MIME-Version: 1.0
226+
Message-Id: <followup_dummy_id>
227+
In-Reply-To: <dummy_test_message_id>
228+
229+
230+
mary <mary@test> added the comment:
231+
232+
A message with first part encoded (encoded oe ö)
233+
183234
----------
184235
status: unread -> chatting
185236
___________________________________________________
@@ -200,6 +251,9 @@ def suite():
200251

201252
#
202253
# $Log: not supported by cvs2svn $
254+
# Revision 1.7 2002/01/22 11:54:45 rochecompaan
255+
# Fixed status change in mail gateway.
256+
#
203257
# Revision 1.6 2002/01/21 10:05:48 rochecompaan
204258
# Feature:
205259
# . the mail gateway now responds with an error message when invalid

0 commit comments

Comments
 (0)