From b42da3a8e5458c9dd7dbc5a8ff67522b14491335 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 10 Jan 2002 06:19:20 +0000 Subject: [PATCH] followup lines directly after a quoted section were being eaten. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@522 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/mailgw.py | 37 +++++++++++++++++++++++++++++-------- test/test_mailsplit.py | 17 ++++++++++++++++- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/roundup/mailgw.py b/roundup/mailgw.py index f1edd3d..186b069 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.48 2002-01-08 04:12:05 richard Exp $ +$Id: mailgw.py,v 1.49 2002-01-10 06:19:18 richard Exp $ ''' @@ -693,21 +693,42 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), if not section: continue lines = eol.split(section) - if lines[0] and lines[0][0] in '>|': - continue - if len(lines) > 1 and lines[1] and lines[1][0] in '>|': - continue + if (lines[0] and lines[0][0] in '>|') or (len(lines) > 1 and + lines[1] and lines[1][0] in '>|'): + # see if there's a response somewhere inside this section (ie. + # no blank line between quoted message and response) + for line in lines[1:]: + if line[0] not in '>|': + break + else: + # TODO: people who want to keep quoted bits will want the + # next line... + # l.append(section) + continue + # keep this section - it has reponse stuff in it + if not summary: + # and while we're at it, use the first non-quoted bit as + # our summary + summary = line + lines = lines[lines.index(line):] + section = '\n'.join(lines) + if not summary: + # if we don't have our summary yet use the first line of this + # section summary = lines[0] - l.append(section) - continue - if signature.match(lines[0]): + elif signature.match(lines[0]): break + + # and add the section to the output l.append(section) return summary, '\n\n'.join(l) # # $Log: not supported by cvs2svn $ +# Revision 1.48 2002/01/08 04:12:05 richard +# Changed message-id format to "<%s.%s.%s%s@%s>" so it complies with RFC822 +# # Revision 1.47 2002/01/02 02:32:38 richard # ANONYMOUS_ACCESS -> ANONYMOUS_REGISTER # diff --git a/test/test_mailsplit.py b/test/test_mailsplit.py index 3dad533..23d30ab 100644 --- a/test/test_mailsplit.py +++ b/test/test_mailsplit.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: test_mailsplit.py,v 1.8 2001-10-28 23:22:28 richard Exp $ +# $Id: test_mailsplit.py,v 1.9 2002-01-10 06:19:20 richard Exp $ import unittest, cStringIO @@ -89,6 +89,18 @@ userfoo@foo.com self.assertEqual(summary, 'testing') self.assertEqual(content, 'testing\n\ntesting\n\ntesting') + def testSimpleFollowup(self): + s = '''>hello\ntesting''' + summary, content = parseContent(s) + self.assertEqual(summary, 'testing') + self.assertEqual(content, 'testing') + + def testSimpleFollowupParas(self): + s = '''>hello\ntesting\n\ntesting\n\ntesting''' + summary, content = parseContent(s) + self.assertEqual(summary, 'testing') + self.assertEqual(content, 'testing\n\ntesting\n\ntesting') + def testEmpty(self): s = '' summary, content = parseContent(s) @@ -111,6 +123,9 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.8 2001/10/28 23:22:28 richard +# fixed bug #474749 ] Indentations lost +# # Revision 1.7 2001/10/23 00:57:32 richard # Removed debug print from mailsplit test. # -- 2.30.2