Skip to content

Commit 64394f9

Browse files
author
Johannes Gijsbers
committed
Make signature matching more precise: only match '-- '...
(note the space) as a signature starter [SF#827775].
1 parent 5d6f611 commit 64394f9

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

roundup/mailgw.py

Lines changed: 2 additions & 2 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.133 2003-10-04 11:21:47 jlgijsbers Exp $
76+
$Id: mailgw.py,v 1.134 2003-10-24 14:59:38 jlgijsbers Exp $
7777
"""
7878

7979
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
@@ -1036,7 +1036,7 @@ def uidFromAddress(db, address, create=1, **user_props):
10361036
def parseContent(content, keep_citations, keep_body,
10371037
blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
10381038
eol=re.compile(r'[\r\n]+'),
1039-
signature=re.compile(r'^[>|\s]*[-_]+\s*$'),
1039+
signature=re.compile(r'^[>|\s]*-- $'),
10401040
original_msg=re.compile(r'^[>|\s]*-----\s?Original Message\s?-----$')):
10411041
''' The message body is divided into sections by blank lines.
10421042
Sections where the second and all subsequent lines begin with a ">"

test/test_mailgw.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
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.53 2003-09-15 19:37:28 jlgijsbers Exp $
11+
# $Id: test_mailgw.py,v 1.54 2003-10-24 14:59:38 jlgijsbers Exp $
1212

1313
import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
1414

1515
from cStringIO import StringIO
1616

17-
from roundup.mailgw import MailGW, Unauthorized, uidFromAddress
17+
from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, parseContent
1818
from roundup import init, instance, rfc2822
1919

2020
NEEDS_INSTANCE = 1
@@ -993,10 +993,27 @@ def testRegistrationConfirmation(self):
993993
handler.main(message)
994994

995995
self.db.user.lookup('johannes')
996-
996+
997+
998+
class ParseContentTestCase(unittest.TestCase):
999+
def testSignatureRemoval(self):
1000+
summary, content = parseContent('''Testing, testing.
1001+
1002+
--
1003+
Signature''', 1, 0)
1004+
self.assertEqual(content, 'Testing, testing.')
1005+
1006+
def testKeepMultipleHyphens(self):
1007+
body = '''Testing, testing.
1008+
1009+
----
1010+
Testing, testing.'''
1011+
summary, content = parseContent(body, 1, 0)
1012+
self.assertEqual(body, content)
1013+
9971014
def suite():
998-
l = [unittest.makeSuite(MailgwTestCase),
999-
]
1015+
l = [#unittest.makeSuite(MailgwTestCase),
1016+
unittest.makeSuite(ParseContentTestCase)]
10001017
return unittest.TestSuite(l)
10011018

10021019

0 commit comments

Comments
 (0)