Skip to content

Commit cafe713

Browse files
author
Richard Jones
committed
fix blank-title subject line handling [SF#1442121]
1 parent a52e979 commit cafe713

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Fixed:
1414
- incompatibility with python2.3 in the mailer module (sf bug 1432602)
1515
- typo in SMTP TLS option name: "MAIL_TLS_CERFILE" (sf bug 1435452)
1616
- email obfuscation code in html templating is more robust
17+
- fix blank-title subject line handling (sf bug 1442121)
1718

1819

1920
2006-02-10 1.1.0

roundup/mailgw.py

Lines changed: 2 additions & 2 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.172 2006-01-25 03:51:21 richard Exp $
75+
$Id: mailgw.py,v 1.173 2006-03-02 23:45:22 richard Exp $
7676
"""
7777
__docformat__ = 'restructuredtext'
7878

@@ -647,7 +647,7 @@ def handle_message(self, message):
647647
# or fallback on the default class
648648
if self.db.config['EMAIL_REGISTRATION_CONFIRMATION']:
649649
otk_re = re.compile('-- key (?P<otk>[a-zA-Z0-9]{32})')
650-
otk = otk_re.search(m.group('title'))
650+
otk = otk_re.search(m.group('title') or '')
651651
if otk:
652652
self.db.confirm_registration(otk.group('otk'))
653653
subject = 'Your registration to %s is complete' % \

scripts/import_sf.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,33 +254,36 @@ def to_date(ts):
254254
else:
255255
d['status'] = unread
256256

257-
messages = []
258257
nosy = sets.Set()
259258
for message in artifact.get('messages', []):
260-
message_id += 1
261259
authid = users[message['user_name']]
262260
if not message['body']: continue
263261
body = convert_message(message['body'], message_id)
264262
if not body: continue
265263
m = {'content': body, 'author': authid,
266-
'date': message['adddate'], 'id': str(message_id),
264+
'date': message['adddate'],
267265
'creation': message['adddate'], }
268266
message_data.append(m)
269-
messages.append(message_id)
270267
if authid not in (None, '2'):
271268
nosy.add(authid)
272269
activity = message['adddate']
273270
actor = authid
274271
if d['status'] == unread:
275272
d['status'] = chatting
276273

277-
message_id += 1
274+
# add import message
278275
m = {'content': 'IMPORT FROM SOURCEFORGE', 'author': '1',
279-
'date': today, 'id': str(message_id), 'creation': today }
276+
'date': today, 'creation': today}
280277
message_data.append(m)
281-
messages.append(message_id)
282278

283-
d['messages'] = messages
279+
# sort messages and assign ids
280+
d['messages'] = []
281+
message_data.sort(lambda a,b:cmp(a['date'],b['date']))
282+
for message in message_data:
283+
message_id += 1
284+
message['id'] = str(message_id)
285+
d['messages'].append(message_id)
286+
284287
d['nosy'] = list(nosy)
285288

286289
files = []

test/test_mailgw.py

Lines changed: 21 additions & 1 deletion
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.76 2005-10-07 04:42:13 richard Exp $
11+
# $Id: test_mailgw.py,v 1.77 2006-03-02 23:45:23 richard Exp $
1212

1313
# TODO: test bcc
1414

@@ -680,6 +680,26 @@ def testFollowupEmptyMessage(self):
680680
In-Reply-To: <dummy_test_message_id>
681681
Subject: [issue1] Testing... [assignedto=mary; nosy=+john]
682682
683+
''')
684+
l = self.db.issue.get('1', 'nosy')
685+
l.sort()
686+
self.assertEqual(l, [self.chef_id, self.richard_id, self.mary_id,
687+
self.john_id])
688+
689+
# should be no file created (ie. no message)
690+
assert not os.path.exists(SENDMAILDEBUG)
691+
692+
def testFollowupEmptyMessageNoSubject(self):
693+
self.doNewIssue()
694+
695+
self._handle_mail('''Content-Type: text/plain;
696+
charset="iso-8859-1"
697+
From: richard <richard@test>
698+
699+
Message-Id: <followup_dummy_id>
700+
In-Reply-To: <dummy_test_message_id>
701+
Subject: [issue1] [assignedto=mary; nosy=+john]
702+
683703
''')
684704
l = self.db.issue.get('1', 'nosy')
685705
l.sort()

0 commit comments

Comments
 (0)