summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5ab6d4d)
raw | patch | inline | side by side (parent: 5ab6d4d)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 13 Nov 2003 03:41:38 +0000 (03:41 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 13 Nov 2003 03:41:38 +0000 (03:41 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1983 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup/mailgw.py | patch | blob | history | |
test/test_mailgw.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index 361eddd7b7a4633e191fda63fabf828293d4fdd5..c26a27c87033c6a2709b7270044f5abd441d08c9 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
since)
- all RDBMS backends now have indexes on several columns
- Change nosymessage and send_message to accept msgid=None (RFE #707235).
+- Handle Resent-From: headers (sf bug 841151)
Fixed:
- mysql documentation fixed to note requirement of 4.0+ and InnoDB
diff --git a/roundup/mailgw.py b/roundup/mailgw.py
index a45f9e96ee438bc99933cdf517f214559ed8277f..50a3c548884685eb2a0e7a2c0d4ac3a85abe87b6 100644 (file)
--- a/roundup/mailgw.py
+++ b/roundup/mailgw.py
an exception, the original message is bounced back to the sender with the
explanatory message given in the exception.
-$Id: mailgw.py,v 1.137 2003-11-11 00:35:13 richard Exp $
+$Id: mailgw.py,v 1.138 2003-11-13 03:41:38 richard Exp $
"""
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
"""
# in some rare cases, a particularly stuffed-up e-mail will make
# its way into here... try to handle it gracefully
- sendto = message.getaddrlist('from')
+ sendto = message.getaddrlist('resent-from')
+ if not sendto:
+ sendto = message.getaddrlist('from')
if sendto:
if not self.trapExceptions:
return self.handle_message(message)
# nodeid = issue.group('nodeid')
# break
+ # determine the sender's address
+ from_list = message.getaddrlist('resent-from')
+ if not from_list:
+ from_list = message.getaddrlist('from')
+
# handle the subject line
subject = message.getheader('subject', '')
self.db.confirm_registration(otk.group('otk'))
subject = 'Your registration to %s is complete' % \
self.instance.config.TRACKER_NAME
- sendto = [message.getheader('from')]
+ sendto = [from_list[0][1]]
self.mailer.standard_message(sendto, subject, '')
return
elif hasattr(self.instance.config, 'MAIL_DEFAULT_CLASS') and \
# ok, now figure out who the author is - create a new user if the
# "create" flag is true
- author = uidFromAddress(self.db, message.getaddrlist('from')[0],
- create=create)
+ author = uidFromAddress(self.db, from_list[0], create=create)
# if we're not recognised, and we don't get added as a user, then we
# must be anonymous
You are not a registered user.
Unknown address: %s
-'''%message.getaddrlist('from')[0][1]
+'''%from_list[0][1]
else:
# we're registered and we're _still_ not allowed access
raise Unauthorized, 'You are not permitted to access '\
diff --git a/test/test_mailgw.py b/test/test_mailgw.py
index 211b4c458a827c714488a3f4c4a11f8a33c09cc7..5ffc55e5351c6882a88bf63c11442de839b6949c 100644 (file)
--- a/test/test_mailgw.py
+++ b/test/test_mailgw.py
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: test_mailgw.py,v 1.61 2003-11-11 00:35:14 richard Exp $
+# $Id: test_mailgw.py,v 1.62 2003-11-13 03:41:38 richard Exp $
import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
# and open the database
self.db = self.instance.open('admin')
- self.db.user.create(username='Chef', address='chef@bork.bork.bork',
- realname='Bork, Chef', roles='User')
- self.db.user.create(username='richard', address='richard@test',
- roles='User')
- self.db.user.create(username='mary', address='mary@test',
+ self.chef_id = self.db.user.create(username='Chef',
+ address='chef@bork.bork.bork', realname='Bork, Chef', roles='User')
+ self.richard_id = self.db.user.create(username='richard',
+ address='richard@test', roles='User')
+ self.mary_id = self.db.user.create(username='mary', address='mary@test',
roles='User', realname='Contrary, Mary')
- self.db.user.create(username='john', address='john@test',
+ self.john_id = self.db.user.create(username='john', address='john@test',
alternate_addresses='jondoe@test\njohn.doe@test', roles='User',
realname='John Doe')
assert not os.path.exists(SENDMAILDEBUG)
l = self.db.issue.get(nodeid, 'nosy')
l.sort()
- self.assertEqual(l, ['3', '4'])
+ self.assertEqual(l, [self.chef_id, self.richard_id])
return nodeid
def testNewIssue(self):
assert not os.path.exists(SENDMAILDEBUG)
l = self.db.issue.get(nodeid, 'nosy')
l.sort()
- self.assertEqual(l, ['3', '4'])
+ self.assertEqual(l, [self.chef_id, self.richard_id])
def testAlternateAddress(self):
self._send_mail('''Content-Type: text/plain;
''')
l = self.db.issue.get('1', 'nosy')
l.sort()
- self.assertEqual(l, ['3', '4', '5', '6'])
+ self.assertEqual(l, [self.chef_id, self.richard_id, self.mary_id,
+ self.john_id])
self.compareMessages(self._get_mail(),
'''FROM: roundup-admin@your.tracker.email.domain.example
''')
l = self.db.issue.get('1', 'nosy')
l.sort()
- self.assertEqual(l, ['3', '4', '5', '6'])
+ self.assertEqual(l, [self.chef_id, self.richard_id, self.mary_id,
+ self.john_id])
# should be no file created (ie. no message)
assert not os.path.exists(SENDMAILDEBUG)
''')
l = self.db.issue.get('1', 'nosy')
l.sort()
- self.assertEqual(l, ['3'])
+ self.assertEqual(l, [self.chef_id])
# NO NOSY MESSAGE SHOULD BE SENT!
assert not os.path.exists(SENDMAILDEBUG)
''')
self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar')
+
+ def testResentFrom(self):
+ nodeid = self._send_mail('''Content-Type: text/plain;
+ charset="iso-8859-1"
+From: Chef <chef@bork.bork.bork>
+Resent-From: mary <mary@test>
+To: issue_tracker@your.tracker.email.domain.example
+Cc: richard@test
+Message-Id: <dummy_test_message_id>
+Subject: [issue] Testing...
+
+This is a test submission of a new issue.
+''')
+ assert not os.path.exists(SENDMAILDEBUG)
+ l = self.db.issue.get(nodeid, 'nosy')
+ l.sort()
+ self.assertEqual(l, [self.richard_id, self.mary_id])
+ return nodeid
def test_suite():
suite = unittest.TestSuite()