Code

followup lines directly after a quoted section were being eaten.
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 10 Jan 2002 06:19:20 +0000 (06:19 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 10 Jan 2002 06:19:20 +0000 (06:19 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@522 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/mailgw.py
test/test_mailsplit.py

index f1edd3d33e0a684e0d77bdba5b2b0b99a700afe1..186b0690c5690ad2a5b279332fe7c7206b09f5b2 100644 (file)
@@ -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
 #
index 3dad533fae5d7a7ad037c001c459fe902e9935f6..23d30abc0b5efb284a9ac31816397022e4fbcff3 100644 (file)
@@ -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.
 #