From 4d5eb5a8fdaec99dd02d6edfbff8b2c29af16104 Mon Sep 17 00:00:00 2001 From: rochecompaan Date: Mon, 18 Mar 2002 18:32:00 +0000 Subject: [PATCH] All messages sent to the nosy list are now encoded as quoted-printable. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@677 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 2 ++ roundup/roundupdb.py | 20 ++++++++++++++++---- test/test_mailgw.py | 32 +++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0800add..5143ab7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -26,6 +26,8 @@ Feature: field won't exist in most installations, but it will be added to the default templates. . #517734 ] web header customisation is obscure + . All messages sent to the nosy list are now encoded as + quoted-printable before they are sent. Fixed: . Clean up mail handling, multipart handling. diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index 0ff49ec..bce5315 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundupdb.py,v 1.47 2002-02-27 03:16:02 richard Exp $ +# $Id: roundupdb.py,v 1.48 2002-03-18 18:32:00 rochecompaan Exp $ __doc__ = """ Extending hyperdb with types specific to issue-tracking. @@ -23,7 +23,7 @@ Extending hyperdb with types specific to issue-tracking. import re, os, smtplib, socket, copy, time, random import MimeWriter, cStringIO -import base64, mimetypes +import base64, quopri, mimetypes import hyperdb, date @@ -398,6 +398,13 @@ class IssueClass(Class): if self.db.config.EMAIL_SIGNATURE_POSITION == 'bottom': m.append(self.email_signature(nodeid, msgid)) + # encode the content as quoted-printable + content = cStringIO.StringIO('\n'.join(m)) + content_encoded = cStringIO.StringIO() + quopri.encode(content, content_encoded, 0) + content_encoded.seek(0) + content_encoded = content_encoded.read() + # get the files for this message message_files = messages.get(msgid, 'files') @@ -423,8 +430,9 @@ class IssueClass(Class): if message_files: part = writer.startmultipartbody('mixed') part = writer.nextpart() + part.addheader('Content-Transfer-Encoding', 'quoted-printable') body = part.startbody('text/plain') - body.write('\n'.join(m)) + body.write(content_encoded) for fileid in message_files: name = files.get(fileid, 'name') mime_type = files.get(fileid, 'type') @@ -450,8 +458,9 @@ class IssueClass(Class): body.write(base64.encodestring(content)) writer.lastpart() else: + writer.addheader('Content-Transfer-Encoding', 'quoted-printable') body = writer.startbody('text/plain') - body.write('\n'.join(m)) + body.write(content_encoded) # now try to send the message if SENDMAILDEBUG: @@ -596,6 +605,9 @@ class IssueClass(Class): # # $Log: not supported by cvs2svn $ +# Revision 1.47 2002/02/27 03:16:02 richard +# Fixed a couple of dodgy bits found by pychekcer. +# # Revision 1.46 2002/02/25 14:22:59 grubert # . roundup db: catch only IOError in getfile. # diff --git a/test/test_mailgw.py b/test/test_mailgw.py index f6a5ba8..c896afc 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.13 2002-02-15 07:08:45 richard Exp $ +# $Id: test_mailgw.py,v 1.14 2002-03-18 18:32:00 rochecompaan Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys @@ -45,7 +45,7 @@ class MailgwTestCase(unittest.TestCase): except OSError, error: if error.errno not in (errno.ENOENT, errno.ESRCH): raise - def xtestNewIssue(self): + def testNewIssue(self): message = cStringIO.StringIO('''Content-Type: text/plain; charset="iso-8859-1" From: Chef MIME-Version: 1.0 Message-Id: X-Roundup-Name: Roundup issue tracker +Content-Transfer-Encoding: quoted-printable New submission from Chef : @@ -152,7 +153,7 @@ ___________________________________________________ # BUG should test some binary attamchent too. - def xtestFollowup(self): + def testFollowup(self): self.testNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; charset="iso-8859-1" @@ -179,6 +180,7 @@ MIME-Version: 1.0 Message-Id: In-Reply-To: X-Roundup-Name: Roundup issue tracker +Content-Transfer-Encoding: quoted-printable richard added the comment: @@ -196,7 +198,7 @@ http://some.useful.url/issue1 ___________________________________________________ ''', 'Generated message not correct') - def xtestFollowup2(self): + def testFollowup2(self): self.testNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; charset="iso-8859-1" @@ -222,6 +224,7 @@ MIME-Version: 1.0 Message-Id: In-Reply-To: X-Roundup-Name: Roundup issue tracker +Content-Transfer-Encoding: quoted-printable mary added the comment: @@ -237,7 +240,7 @@ http://some.useful.url/issue1 ___________________________________________________ ''', 'Generated message not correct') - def xtestFollowupTitleMatch(self): + def testFollowupTitleMatch(self): self.testNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; charset="iso-8859-1" @@ -264,6 +267,7 @@ MIME-Version: 1.0 Message-Id: In-Reply-To: X-Roundup-Name: Roundup issue tracker +Content-Transfer-Encoding: quoted-printable richard added the comment: @@ -281,7 +285,7 @@ http://some.useful.url/issue1 ___________________________________________________ ''') #, 'Generated message not correct') - def xtestEnc01(self): + def testEnc01(self): self.testNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; charset="iso-8859-1" @@ -312,11 +316,12 @@ MIME-Version: 1.0 Message-Id: In-Reply-To: X-Roundup-Name: Roundup issue tracker +Content-Transfer-Encoding: quoted-printable mary added the comment: -A message with encoding (encoded oe ö) +A message with encoding (encoded oe =F6) ---------- status: unread -> chatting @@ -327,7 +332,7 @@ ___________________________________________________ ''', 'Generated message not correct') - def xtestMultipartEnc01(self): + def testMultipartEnc01(self): self.testNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; charset="iso-8859-1" @@ -365,11 +370,12 @@ MIME-Version: 1.0 Message-Id: In-Reply-To: X-Roundup-Name: Roundup issue tracker +Content-Transfer-Encoding: quoted-printable mary added the comment: -A message with first part encoded (encoded oe ö) +A message with first part encoded (encoded oe =F6) ---------- status: unread -> chatting @@ -391,6 +397,10 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.13 2002/02/15 07:08:45 richard +# . Alternate email addresses are now available for users. See the MIGRATION +# file for info on how to activate the feature. +# # Revision 1.12 2002/02/15 00:13:38 richard # . #503204 ] mailgw needs a default class # - partially done - the setting of additional properties can wait for a -- 2.30.2