From: jlgijsbers Date: Fri, 24 Oct 2003 14:59:38 +0000 (+0000) Subject: Make signature matching more precise: only match '-- ' (note the X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7db085c146020e8ca47d9890829b7379bdb51411;p=roundup.git Make signature matching more precise: only match '-- ' (note the space) as a signature starter (bug #827775). git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1928 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 8ec27fe..c4a6780 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.133 2003-10-04 11:21:47 jlgijsbers Exp $ +$Id: mailgw.py,v 1.134 2003-10-24 14:59:38 jlgijsbers Exp $ """ import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri @@ -1036,7 +1036,7 @@ def uidFromAddress(db, address, create=1, **user_props): def parseContent(content, keep_citations, keep_body, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), eol=re.compile(r'[\r\n]+'), - signature=re.compile(r'^[>|\s]*[-_]+\s*$'), + signature=re.compile(r'^[>|\s]*-- $'), original_msg=re.compile(r'^[>|\s]*-----\s?Original Message\s?-----$')): ''' The message body is divided into sections by blank lines. Sections where the second and all subsequent lines begin with a ">" diff --git a/test/test_mailgw.py b/test/test_mailgw.py index 83656fc..152f180 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -8,13 +8,13 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.53 2003-09-15 19:37:28 jlgijsbers Exp $ +# $Id: test_mailgw.py,v 1.54 2003-10-24 14:59:38 jlgijsbers Exp $ import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 from cStringIO import StringIO -from roundup.mailgw import MailGW, Unauthorized, uidFromAddress +from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, parseContent from roundup import init, instance, rfc2822 NEEDS_INSTANCE = 1 @@ -993,10 +993,27 @@ This is a test confirmation of registration. handler.main(message) self.db.user.lookup('johannes') - + + +class ParseContentTestCase(unittest.TestCase): + def testSignatureRemoval(self): + summary, content = parseContent('''Testing, testing. + +-- +Signature''', 1, 0) + self.assertEqual(content, 'Testing, testing.') + + def testKeepMultipleHyphens(self): + body = '''Testing, testing. + +---- +Testing, testing.''' + summary, content = parseContent(body, 1, 0) + self.assertEqual(body, content) + def suite(): - l = [unittest.makeSuite(MailgwTestCase), - ] + l = [#unittest.makeSuite(MailgwTestCase), + unittest.makeSuite(ParseContentTestCase)] return unittest.TestSuite(l)