From f5b40d323fc1138d401c14fcb1daf7f780f3ae8a Mon Sep 17 00:00:00 2001 From: grubert Date: Mon, 4 Feb 2002 09:40:21 +0000 Subject: [PATCH] . add test for multipart messages with first part being encoded. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@608 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/mailgw.py | 7 +++++- test/test_mailgw.py | 56 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/roundup/mailgw.py b/roundup/mailgw.py index fa53305..bf02c3b 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.60 2002-02-01 07:43:12 grubert Exp $ +$Id: mailgw.py,v 1.61 2002-02-04 09:40:21 grubert Exp $ ''' @@ -495,6 +495,8 @@ Unknown address: %s # assume first part is the mail encoding = part.getencoding() if encoding == 'base64': + # BUG: is base64 really used for text encoding or + # are we inserting zip files here. data = binascii.a2b_base64(part.fp.read()) elif encoding == 'quoted-printable': # 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]+'), # # $Log: not supported by cvs2svn $ +# Revision 1.60 2002/02/01 07:43:12 grubert +# . mailgw checks encoding on first part too. +# # Revision 1.59 2002/01/23 21:43:23 richard # tabnuke # diff --git a/test/test_mailgw.py b/test/test_mailgw.py index d385334..cb53984 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.7 2002-01-22 11:54:45 rochecompaan Exp $ +# $Id: test_mailgw.py,v 1.8 2002-02-04 09:40:21 grubert Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys @@ -180,6 +180,57 @@ mary added the comment: This is a second followup +---------- +status: unread -> chatting +___________________________________________________ +"Roundup issue tracker" +http://some.useful.url/issue1 +___________________________________________________ +''', 'Generated message not correct') + + def testMultipartEnc01(self): + self.testNewIssue() + message = cStringIO.StringIO('''Content-Type: text/plain; + charset="iso-8859-1" +From: mary +To: issue_tracker@fill.me.in. +Message-Id: +In-Reply-To: +Subject: [issue1] Testing... +Content-Type: multipart/mixed; + boundary="----_=_NextPart_000_01" + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_000_01 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +A message with first part encoded (encoded oe =F6) + +''') + handler = self.instance.MailGW(self.instance, self.db) + handler.main(message) + message_data = open(os.environ['SENDMAILDEBUG']).read() + self.assertEqual(message_data, +'''FROM: roundup-admin@fill.me.in. +TO: chef@bork.bork.bork, richard@test +Content-Type: text/plain +Subject: [issue1] Testing... +To: chef@bork.bork.bork, richard@test +From: mary +Reply-To: Roundup issue tracker +MIME-Version: 1.0 +Message-Id: +In-Reply-To: + + +mary added the comment: + +A message with first part encoded (encoded oe รถ) + ---------- status: unread -> chatting ___________________________________________________ @@ -200,6 +251,9 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.7 2002/01/22 11:54:45 rochecompaan +# Fixed status change in mail gateway. +# # Revision 1.6 2002/01/21 10:05:48 rochecompaan # Feature: # . the mail gateway now responds with an error message when invalid -- 2.30.2