changeset 3367:a23863a95326

handle missing Subject lines better [SF#1198729]
author Richard Jones <richard@users.sourceforge.net>
date Fri, 24 Jun 2005 06:47:44 +0000
parents e2d65f6c8d83
children 18f1631c9b85
files CHANGES.txt doc/index.txt roundup/mailgw.py test/test_mailgw.py
diffstat 4 files changed, 29 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Fri Jun 24 06:38:14 2005 +0000
+++ b/CHANGES.txt	Fri Jun 24 06:47:44 2005 +0000
@@ -25,6 +25,7 @@
 - allow specification of pagesize, sorting and filtering in "classhelp"
   popups (sf bug 1211800)
 - handle dropped properies in rdbms/metakit journal export (sf bug 1203569)
+- handle missing Subject lines better (sf bug 1198729)
 
 
 2005-05-02 0.8.3
--- a/doc/index.txt	Fri Jun 24 06:38:14 2005 +0000
+++ b/doc/index.txt	Fri Jun 24 06:47:44 2005 +0000
@@ -128,6 +128,7 @@
 John P. Rouillard,
 Ollie Rutherfurd,
 Toby Sargeant,
+Giuseppe Scelsi,
 Gregor Schmid,
 Florian Schulze,
 Klamer Schutte,
--- a/roundup/mailgw.py	Fri Jun 24 06:38:14 2005 +0000
+++ b/roundup/mailgw.py	Fri Jun 24 06:47:44 2005 +0000
@@ -72,7 +72,7 @@
 an exception, the original message is bounced back to the sender with the
 explanatory message given in the exception.
 
-$Id: mailgw.py,v 1.164 2005-04-13 03:38:22 richard Exp $
+$Id: mailgw.py,v 1.165 2005-06-24 06:43:03 richard Exp $
 """
 __docformat__ = 'restructuredtext'
 
@@ -579,11 +579,21 @@
         if message.getheader('x-roundup-loop', ''):
             raise IgnoreLoop
 
+        # handle the subject line
+        subject = message.getheader('subject', '')
+        if not subject:
+            raise MailUsageError, '''
+Emails to Roundup trackers must include a Subject: line!
+'''
+
         # detect Precedence: Bulk, or Microsoft Outlook autoreplies
         if (message.getheader('precedence', '') == 'bulk'
-            or message.getheader('subject', '').lower().find("autoreply") > 0):
+                or subject.lower().find("autoreply") > 0):
             raise IgnoreBulk
 
+        if subject.strip().lower() == 'help':
+            raise MailUsageHelp
+
         # config is used many times in this method.
         # make local variable for easier access
         config = self.instance.config
@@ -609,20 +619,8 @@
         if not from_list:
             from_list = message.getaddrlist('from')
 
-        # handle the subject line
-        subject = message.getheader('subject', '')
-
-        if not subject:
-            raise MailUsageError, '''
-Emails to Roundup trackers must include a Subject: line!
-'''
-
-        if subject.strip().lower() == 'help':
-            raise MailUsageHelp
-
+        # check for well-formed subject line
         m = self.subject_re.match(subject)
-
-        # check for well-formed subject line
         if m:
             # get the classname
             classname = m.group('classname')
--- a/test/test_mailgw.py	Fri Jun 24 06:38:14 2005 +0000
+++ b/test/test_mailgw.py	Fri Jun 24 06:47:44 2005 +0000
@@ -8,7 +8,7 @@
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
-# $Id: test_mailgw.py,v 1.74 2005-02-14 05:54:41 richard Exp $
+# $Id: test_mailgw.py,v 1.75 2005-06-24 06:47:44 richard Exp $
 
 # TODO: test bcc
 
@@ -21,7 +21,7 @@
 SENDMAILDEBUG = os.environ['SENDMAILDEBUG']
 
 from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, \
-    parseContent, IgnoreLoop, IgnoreBulk
+    parseContent, IgnoreLoop, IgnoreBulk, MailUsageError
 from roundup import init, instance, password, rfc2822, __version__
 
 import db_test_base
@@ -1020,6 +1020,18 @@
 Hi, I'm back in the office next week
 ''')
 
+    def testNoSubject(self):
+        self.assertRaises(MailUsageError, self._handle_mail,
+            '''Content-Type: text/plain;
+  charset="iso-8859-1"
+From: Chef <chef@bork.bork.bork>
+To: issue_tracker@your.tracker.email.domain.example
+Cc: richard@test
+Reply-To: chef@bork.bork.bork
+Message-Id: <dummy_test_message_id>
+
+''')
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(MailgwTestCase))

Roundup Issue Tracker: http://roundup-tracker.org/