Skip to content

Commit e84efa1

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent 8b4b959 commit e84efa1

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Fixed:
1818
- allow specification of pagesize, sorting and filtering in "classhelp"
1919
popups (sf bug 1211800)
2020
- handle dropped properies in rdbms/metakit journal export (sf bug 1203569)
21+
- handle missing Subject lines better (sf bug 1198729)
2122

2223

2324
2005-05-02 0.8.3

doc/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Roy Rapoport,
128128
John P. Rouillard,
129129
Ollie Rutherfurd,
130130
Toby Sargeant,
131+
Giuseppe Scelsi,
131132
Gregor Schmid,
132133
Florian Schulze,
133134
Klamer Schutte,

roundup/mailgw.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class node. Any parts of other types are each stored in separate files
7272
an exception, the original message is bounced back to the sender with the
7373
explanatory message given in the exception.
7474
75-
$Id: mailgw.py,v 1.159.2.4 2005-02-15 23:42:30 richard Exp $
75+
$Id: mailgw.py,v 1.159.2.5 2005-06-24 06:48:17 richard Exp $
7676
"""
7777
__docformat__ = 'restructuredtext'
7878

@@ -579,11 +579,21 @@ def handle_message(self, message):
579579
if message.getheader('x-roundup-loop', ''):
580580
raise IgnoreLoop
581581

582+
# handle the subject line
583+
subject = message.getheader('subject', '')
584+
if not subject:
585+
raise MailUsageError, '''
586+
Emails to Roundup trackers must include a Subject: line!
587+
'''
588+
582589
# detect Precedence: Bulk, or Microsoft Outlook autoreplies
583590
if (message.getheader('precedence', '') == 'bulk'
584-
or message.getheader('subject', '').lower().find("autoreply") > 0):
591+
or subject.lower().find("autoreply") > 0):
585592
raise IgnoreBulk
586593

594+
if subject.strip().lower() == 'help':
595+
raise MailUsageHelp
596+
587597
# config is used many times in this method.
588598
# make local variable for easier access
589599
config = self.instance.config
@@ -609,20 +619,8 @@ def handle_message(self, message):
609619
if not from_list:
610620
from_list = message.getaddrlist('from')
611621

612-
# handle the subject line
613-
subject = message.getheader('subject', '')
614-
615-
if not subject:
616-
raise MailUsageError, '''
617-
Emails to Roundup trackers must include a Subject: line!
618-
'''
619-
620-
if subject.strip().lower() == 'help':
621-
raise MailUsageHelp
622-
623-
m = self.subject_re.match(subject)
624-
625622
# check for well-formed subject line
623+
m = self.subject_re.match(subject)
626624
if m:
627625
# get the classname
628626
classname = m.group('classname')

test/test_mailgw.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_mailgw.py,v 1.73.2.1 2005-02-14 05:55:20 richard Exp $
11+
# $Id: test_mailgw.py,v 1.73.2.2 2005-06-24 06:48:17 richard Exp $
1212

1313
# TODO: test bcc
1414

@@ -21,7 +21,7 @@
2121
SENDMAILDEBUG = os.environ['SENDMAILDEBUG']
2222

2323
from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, \
24-
parseContent, IgnoreLoop, IgnoreBulk
24+
parseContent, IgnoreLoop, IgnoreBulk, MailUsageError
2525
from roundup import init, instance, password, rfc2822, __version__
2626

2727
import db_test_base
@@ -1018,6 +1018,18 @@ def testAutoReplyEmailsAreIgnored(self):
10181018
Subject: Re: [issue] Out of office AutoReply: Back next week
10191019
10201020
Hi, I'm back in the office next week
1021+
''')
1022+
1023+
def testNoSubject(self):
1024+
self.assertRaises(MailUsageError, self._handle_mail,
1025+
'''Content-Type: text/plain;
1026+
charset="iso-8859-1"
1027+
From: Chef <[email protected]>
1028+
1029+
Cc: richard@test
1030+
1031+
Message-Id: <dummy_test_message_id>
1032+
10211033
''')
10221034

10231035
def test_suite():

0 commit comments

Comments
 (0)