Skip to content

Commit 9a99506

Browse files
author
Roche Compaan
committed
All messages sent to the nosy list are now encoded as quoted-printable.
1 parent 486f7e3 commit 9a99506

File tree

3 files changed

+39
-15
lines changed

3 files changed

+39
-15
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Feature:
2626
field won't exist in most installations, but it will be added to the
2727
default templates.
2828
. #517734 ] web header customisation is obscure
29+
. All messages sent to the nosy list are now encoded as
30+
quoted-printable before they are sent.
2931

3032
Fixed:
3133
. Clean up mail handling, multipart handling.

roundup/roundupdb.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.47 2002-02-27 03:16:02 richard Exp $
18+
# $Id: roundupdb.py,v 1.48 2002-03-18 18:32:00 rochecompaan Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
2222
"""
2323

2424
import re, os, smtplib, socket, copy, time, random
2525
import MimeWriter, cStringIO
26-
import base64, mimetypes
26+
import base64, quopri, mimetypes
2727

2828
import hyperdb, date
2929

@@ -398,6 +398,13 @@ def sendmessage(self, nodeid, msgid, change_note):
398398
if self.db.config.EMAIL_SIGNATURE_POSITION == 'bottom':
399399
m.append(self.email_signature(nodeid, msgid))
400400

401+
# encode the content as quoted-printable
402+
content = cStringIO.StringIO('\n'.join(m))
403+
content_encoded = cStringIO.StringIO()
404+
quopri.encode(content, content_encoded, 0)
405+
content_encoded.seek(0)
406+
content_encoded = content_encoded.read()
407+
401408
# get the files for this message
402409
message_files = messages.get(msgid, 'files')
403410

@@ -423,8 +430,9 @@ def sendmessage(self, nodeid, msgid, change_note):
423430
if message_files:
424431
part = writer.startmultipartbody('mixed')
425432
part = writer.nextpart()
433+
part.addheader('Content-Transfer-Encoding', 'quoted-printable')
426434
body = part.startbody('text/plain')
427-
body.write('\n'.join(m))
435+
body.write(content_encoded)
428436
for fileid in message_files:
429437
name = files.get(fileid, 'name')
430438
mime_type = files.get(fileid, 'type')
@@ -450,8 +458,9 @@ def sendmessage(self, nodeid, msgid, change_note):
450458
body.write(base64.encodestring(content))
451459
writer.lastpart()
452460
else:
461+
writer.addheader('Content-Transfer-Encoding', 'quoted-printable')
453462
body = writer.startbody('text/plain')
454-
body.write('\n'.join(m))
463+
body.write(content_encoded)
455464

456465
# now try to send the message
457466
if SENDMAILDEBUG:
@@ -596,6 +605,9 @@ def generateChangeNote(self, nodeid, oldvalues):
596605

597606
#
598607
# $Log: not supported by cvs2svn $
608+
# Revision 1.47 2002/02/27 03:16:02 richard
609+
# Fixed a couple of dodgy bits found by pychekcer.
610+
#
599611
# Revision 1.46 2002/02/25 14:22:59 grubert
600612
# . roundup db: catch only IOError in getfile.
601613
#

test/test_mailgw.py

Lines changed: 21 additions & 11 deletions
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.13 2002-02-15 07:08:45 richard Exp $
11+
# $Id: test_mailgw.py,v 1.14 2002-03-18 18:32:00 rochecompaan Exp $
1212

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

@@ -45,7 +45,7 @@ def tearDown(self):
4545
except OSError, error:
4646
if error.errno not in (errno.ENOENT, errno.ESRCH): raise
4747

48-
def xtestNewIssue(self):
48+
def testNewIssue(self):
4949
message = cStringIO.StringIO('''Content-Type: text/plain;
5050
charset="iso-8859-1"
5151
From: Chef <[email protected]
@@ -81,7 +81,7 @@ def testAlternateAddress(self):
8181
self.assertEqual(userlist, self.db.user.list(),
8282
"user created when it shouldn't have been")
8383

84-
def xtestNewIssueNoClass(self):
84+
def testNewIssueNoClass(self):
8585
message = cStringIO.StringIO('''Content-Type: text/plain;
8686
charset="iso-8859-1"
8787
From: Chef <[email protected]
@@ -98,7 +98,7 @@ def xtestNewIssueNoClass(self):
9898
error = open(os.environ['SENDMAILDEBUG']).read()
9999
self.assertEqual('no error', error)
100100

101-
def xtestNewIssueAuthMsg(self):
101+
def testNewIssueAuthMsg(self):
102102
message = cStringIO.StringIO('''Content-Type: text/plain;
103103
charset="iso-8859-1"
104104
From: Chef <[email protected]
@@ -124,6 +124,7 @@ def xtestNewIssueAuthMsg(self):
124124
MIME-Version: 1.0
125125
Message-Id: <dummy_test_message_id>
126126
X-Roundup-Name: Roundup issue tracker
127+
Content-Transfer-Encoding: quoted-printable
127128
128129
129130
New submission from Chef <[email protected]>:
@@ -152,7 +153,7 @@ def xtestNewIssueAuthMsg(self):
152153

153154
# BUG should test some binary attamchent too.
154155

155-
def xtestFollowup(self):
156+
def testFollowup(self):
156157
self.testNewIssue()
157158
message = cStringIO.StringIO('''Content-Type: text/plain;
158159
charset="iso-8859-1"
@@ -179,6 +180,7 @@ def xtestFollowup(self):
179180
Message-Id: <followup_dummy_id>
180181
In-Reply-To: <dummy_test_message_id>
181182
X-Roundup-Name: Roundup issue tracker
183+
Content-Transfer-Encoding: quoted-printable
182184
183185
184186
richard <richard@test> added the comment:
@@ -196,7 +198,7 @@ def xtestFollowup(self):
196198
___________________________________________________
197199
''', 'Generated message not correct')
198200

199-
def xtestFollowup2(self):
201+
def testFollowup2(self):
200202
self.testNewIssue()
201203
message = cStringIO.StringIO('''Content-Type: text/plain;
202204
charset="iso-8859-1"
@@ -222,6 +224,7 @@ def xtestFollowup2(self):
222224
Message-Id: <followup_dummy_id>
223225
In-Reply-To: <dummy_test_message_id>
224226
X-Roundup-Name: Roundup issue tracker
227+
Content-Transfer-Encoding: quoted-printable
225228
226229
227230
mary <mary@test> added the comment:
@@ -237,7 +240,7 @@ def xtestFollowup2(self):
237240
___________________________________________________
238241
''', 'Generated message not correct')
239242

240-
def xtestFollowupTitleMatch(self):
243+
def testFollowupTitleMatch(self):
241244
self.testNewIssue()
242245
message = cStringIO.StringIO('''Content-Type: text/plain;
243246
charset="iso-8859-1"
@@ -264,6 +267,7 @@ def xtestFollowupTitleMatch(self):
264267
Message-Id: <followup_dummy_id>
265268
In-Reply-To: <dummy_test_message_id>
266269
X-Roundup-Name: Roundup issue tracker
270+
Content-Transfer-Encoding: quoted-printable
267271
268272
269273
richard <richard@test> added the comment:
@@ -281,7 +285,7 @@ def xtestFollowupTitleMatch(self):
281285
___________________________________________________
282286
''') #, 'Generated message not correct')
283287

284-
def xtestEnc01(self):
288+
def testEnc01(self):
285289
self.testNewIssue()
286290
message = cStringIO.StringIO('''Content-Type: text/plain;
287291
charset="iso-8859-1"
@@ -312,11 +316,12 @@ def xtestEnc01(self):
312316
Message-Id: <followup_dummy_id>
313317
In-Reply-To: <dummy_test_message_id>
314318
X-Roundup-Name: Roundup issue tracker
319+
Content-Transfer-Encoding: quoted-printable
315320
316321
317322
mary <mary@test> added the comment:
318323
319-
A message with encoding (encoded oe ö)
324+
A message with encoding (encoded oe =F6)
320325
321326
----------
322327
status: unread -> chatting
@@ -327,7 +332,7 @@ def xtestEnc01(self):
327332
''', 'Generated message not correct')
328333

329334

330-
def xtestMultipartEnc01(self):
335+
def testMultipartEnc01(self):
331336
self.testNewIssue()
332337
message = cStringIO.StringIO('''Content-Type: text/plain;
333338
charset="iso-8859-1"
@@ -365,11 +370,12 @@ def xtestMultipartEnc01(self):
365370
Message-Id: <followup_dummy_id>
366371
In-Reply-To: <dummy_test_message_id>
367372
X-Roundup-Name: Roundup issue tracker
373+
Content-Transfer-Encoding: quoted-printable
368374
369375
370376
mary <mary@test> added the comment:
371377
372-
A message with first part encoded (encoded oe ö)
378+
A message with first part encoded (encoded oe =F6)
373379
374380
----------
375381
status: unread -> chatting
@@ -391,6 +397,10 @@ def suite():
391397

392398
#
393399
# $Log: not supported by cvs2svn $
400+
# Revision 1.13 2002/02/15 07:08:45 richard
401+
# . Alternate email addresses are now available for users. See the MIGRATION
402+
# file for info on how to activate the feature.
403+
#
394404
# Revision 1.12 2002/02/15 00:13:38 richard
395405
# . #503204 ] mailgw needs a default class
396406
# - partially done - the setting of additional properties can wait for a

0 commit comments

Comments
 (0)