Skip to content

Commit e7ec39c

Browse files
author
Richard Jones
committed
followup lines directly after a quoted section were being eaten.
1 parent fb0568b commit e7ec39c

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

roundup/mailgw.py

Lines changed: 29 additions & 8 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.48 2002-01-08 04:12:05 richard Exp $
76+
$Id: mailgw.py,v 1.49 2002-01-10 06:19:18 richard Exp $
7777
'''
7878

7979

@@ -693,21 +693,42 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
693693
if not section:
694694
continue
695695
lines = eol.split(section)
696-
if lines[0] and lines[0][0] in '>|':
697-
continue
698-
if len(lines) > 1 and lines[1] and lines[1][0] in '>|':
699-
continue
696+
if (lines[0] and lines[0][0] in '>|') or (len(lines) > 1 and
697+
lines[1] and lines[1][0] in '>|'):
698+
# see if there's a response somewhere inside this section (ie.
699+
# no blank line between quoted message and response)
700+
for line in lines[1:]:
701+
if line[0] not in '>|':
702+
break
703+
else:
704+
# TODO: people who want to keep quoted bits will want the
705+
# next line...
706+
# l.append(section)
707+
continue
708+
# keep this section - it has reponse stuff in it
709+
if not summary:
710+
# and while we're at it, use the first non-quoted bit as
711+
# our summary
712+
summary = line
713+
lines = lines[lines.index(line):]
714+
section = '\n'.join(lines)
715+
700716
if not summary:
717+
# if we don't have our summary yet use the first line of this
718+
# section
701719
summary = lines[0]
702-
l.append(section)
703-
continue
704-
if signature.match(lines[0]):
720+
elif signature.match(lines[0]):
705721
break
722+
723+
# and add the section to the output
706724
l.append(section)
707725
return summary, '\n\n'.join(l)
708726

709727
#
710728
# $Log: not supported by cvs2svn $
729+
# Revision 1.48 2002/01/08 04:12:05 richard
730+
# Changed message-id format to "<%s.%s.%s%s@%s>" so it complies with RFC822
731+
#
711732
# Revision 1.47 2002/01/02 02:32:38 richard
712733
# ANONYMOUS_ACCESS -> ANONYMOUS_REGISTER
713734
#

test/test_mailsplit.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: test_mailsplit.py,v 1.8 2001-10-28 23:22:28 richard Exp $
18+
# $Id: test_mailsplit.py,v 1.9 2002-01-10 06:19:20 richard Exp $
1919

2020
import unittest, cStringIO
2121

@@ -89,6 +89,18 @@ def testParagraphs(self):
8989
self.assertEqual(summary, 'testing')
9090
self.assertEqual(content, 'testing\n\ntesting\n\ntesting')
9191

92+
def testSimpleFollowup(self):
93+
s = '''>hello\ntesting'''
94+
summary, content = parseContent(s)
95+
self.assertEqual(summary, 'testing')
96+
self.assertEqual(content, 'testing')
97+
98+
def testSimpleFollowupParas(self):
99+
s = '''>hello\ntesting\n\ntesting\n\ntesting'''
100+
summary, content = parseContent(s)
101+
self.assertEqual(summary, 'testing')
102+
self.assertEqual(content, 'testing\n\ntesting\n\ntesting')
103+
92104
def testEmpty(self):
93105
s = ''
94106
summary, content = parseContent(s)
@@ -111,6 +123,9 @@ def suite():
111123

112124
#
113125
# $Log: not supported by cvs2svn $
126+
# Revision 1.8 2001/10/28 23:22:28 richard
127+
# fixed bug #474749 ] Indentations lost
128+
#
114129
# Revision 1.7 2001/10/23 00:57:32 richard
115130
# Removed debug print from mailsplit test.
116131
#

0 commit comments

Comments
 (0)