Skip to content

Commit 7bf7f43

Browse files
author
Ralf Schlatterbeck
committed
Fix file-unlink bug in mailgw
(Ralfs oversight when refactoring the mail gateway code) -- if a message is sent that contains no attachments, all previous files of the issue are unlinked, thanks to Rafal Bisingier for reporting and proposing a fix. I've now added a regression test that catches this issue.
1 parent 864e2e2 commit 7bf7f43

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

CHANGES.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@ This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first. If no other name is given,
33
Richard Jones did the change.
44

5-
2011-XX-XX 1.X.XX (rXXXX)
5+
2011-05-29 1.4.18 (rXXXX)
66

77
Features:
88

99
- Norwegian Bokmal translation by Christian Aastorp
1010
- Allow to specify additional cc and bcc emails (not roundup users) for
11-
nosymessage used by the nosyreaction reactor.
11+
nosymessage used by the nosyreaction reactor. (Ralf)
12+
13+
Fixed:
14+
15+
- Fix file-unlink bug in mailgw (Ralfs oversight when refactoring the mail
16+
gateway code) -- if a message is sent that contains no attachments,
17+
all previous files of the issue are unlinked, thanks to Rafal
18+
Bisingier for reporting and proposing a fix.
19+
I've now added a regression test that catches this issue.
1220

1321
2011-05-13 1.4.17 (r4605)
1422

doc/acknowledgements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Anthony Baxter,
1414
Marlon van den Berg,
1515
Bo Berglund,
1616
Stéphane Bidoul,
17+
Rafal Bisingier,
1718
Cameron Blackwood,
1819
Jeff Blaine,
1920
Duncan Booth,

roundup/mailgw.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ def create_files(self):
10581058
fileprop.extend(files)
10591059
files = fileprop
10601060

1061-
self.props['files'] = files
1061+
self.props['files'] = files
10621062

10631063
def create_msg(self):
10641064
''' Create msg containing all the relevant information from the message
@@ -1093,7 +1093,8 @@ def create_msg(self):
10931093
try:
10941094
message_id = self.db.msg.create(author=self.author,
10951095
recipients=self.recipients, date=date.Date('.'),
1096-
summary=summary, content=content, files=self.props['files'],
1096+
summary=summary, content=content,
1097+
files=self.props.get('files',[]),
10971098
messageid=messageid, inreplyto=inreplyto, **msg_props)
10981099
except exceptions.Reject, error:
10991100
raise MailUsageError, _("""

test/test_mailgw.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,36 @@ def testMultipartKeepAlternatives(self):
625625
self.assertEqual(f.content, content [n])
626626
self.assertEqual(msg.content, 'test attachment second text/plain')
627627

628+
def testMultipartKeepFiles(self):
629+
self.doNewIssue()
630+
self._handle_mail(self.multipart_msg)
631+
messages = self.db.issue.get('1', 'messages')
632+
messages.sort()
633+
msg = self.db.msg.getnode (messages[-1])
634+
assert(len(msg.files) == 5)
635+
issue = self.db.issue.getnode ('1')
636+
assert(len(issue.files) == 5)
637+
names = {0 : 'first.dvi', 4 : 'second.dvi'}
638+
content = {3 : 'test attachment third text/plain\n',
639+
4 : 'Just a test\n'}
640+
for n, id in enumerate (msg.files):
641+
f = self.db.file.getnode (id)
642+
self.assertEqual(f.name, names.get (n, 'unnamed'))
643+
if n in content :
644+
self.assertEqual(f.content, content [n])
645+
self.assertEqual(msg.content, 'test attachment second text/plain')
646+
self._handle_mail('''From: mary <[email protected]>
647+
648+
Message-Id: <followup_dummy_id2>
649+
In-Reply-To: <dummy_test_message_id>
650+
Subject: [issue1] Testing...
651+
652+
This ist a message without attachment
653+
''')
654+
issue = self.db.issue.getnode ('1')
655+
assert(len(issue.files) == 5)
656+
self.assertEqual(issue.files, ['1', '2', '3', '4', '5'])
657+
628658
def testMultipartDropAlternatives(self):
629659
self.doNewIssue()
630660
self.db.config.MAILGW_IGNORE_ALTERNATIVES = True

0 commit comments

Comments
 (0)