# HG changeset patch # User Peter Funk # Date 1458314300 -3600 # Fri Mar 18 16:18:20 2016 +0100 # Branch resent-from-patch # Node ID 8ea6d8eb2b14b335dc73b06171e52bd82590d1d1 # Parent dce3cfe7ec61f9ebab42bf1dcaa04db8ff946860 Fix issue1615201: Added a new configuration option EMAIL_KEEP_REAL_FROM which makes the mail gateway ignore a Resent-From:-header and use the real From:-header of the original author for further processing of the message. Setting this option to 'yes' restores the original behaviour of Roundup before the change in version 0.7.0 where the processing of Resent-From: was added unconditionally. diff -r dce3cfe7ec61 -r 8ea6d8eb2b14 CHANGES.txt --- a/CHANGES.txt Wed Feb 11 00:44:16 2015 +1100 +++ b/CHANGES.txt Fri Mar 18 16:18:20 2016 +0100 @@ -6,10 +6,10 @@ Each entry has the developer who committed the change in brackets. Entries without name were done by Richard Jones. -**IMPORTANT** The v1.5.x releases of Roundup will be the last to support -Python v2.5. Support for Python v2.5 will be dropped with the v1.6 -release of Roundup, at which point users will need to run Roundup using -either Python v2.6 or v2.7. +**IMPORTANT** The v1.5.x releases of Roundup were the last to support +Python v2.5. Support for Python v2.5 is dropped starting with the v1.6.x +releases of Roundup, at which point either Python v2.6 or v2.7 is +required to run those releases of Roundup. 201?-??-??: 1.6.0 @@ -20,7 +20,10 @@ Fixed -- (none yet) +- issue1615201: Optionally restore the original (version 0.6) mailgw + behaviour of ignoring a Resent-From:-header and using the real + From-header instead: new configuration option EMAIL_KEEP_REAL_FROM + (Peter Funk aka Pefu). 2016-01-11: 1.5.1 diff -r dce3cfe7ec61 -r 8ea6d8eb2b14 doc/user_guide.txt --- a/doc/user_guide.txt Wed Feb 11 00:44:16 2015 +1100 +++ b/doc/user_guide.txt Fri Mar 18 16:18:20 2016 +0100 @@ -549,6 +549,10 @@ creates a new issue. If 'yes', then the recipients will be added on followups too. If 'no', they're never added to the nosy. +Some organisations might prefer to have someone moderate emails before +they are delivered into Roundup. Those might want to set the +configuration option ``EMAIL_KEEP_REAL_FROM`` to ``'yes'`` to avoid +having the moderators address appearing as the creator of issues. Nosy List ~~~~~~~~~ diff -r dce3cfe7ec61 -r 8ea6d8eb2b14 roundup/configuration.py --- a/roundup/configuration.py Wed Feb 11 00:44:16 2015 +1100 +++ b/roundup/configuration.py Fri Mar 18 16:18:20 2016 +0100 @@ -818,7 +818,13 @@ "multipart/alternative, and this option is set, all other\n" "parts of the multipart/alternative are ignored. The default\n" "is to keep all parts and attach them to the issue."), - ), "Roundup Mail Gateway options"), + (BooleanOption, "keep_real_from", "no", + "When handling emails ignore the Resent-From:-header\n" + "and use the original senders From:-header instead.\n" + "(This might be desirable in some situations where a moderator\n" + "reads incoming messages first before bouncing them to Roundup)", + ["EMAIL_KEEP_REAL_FROM"]), + ), "Roundup Mail Gateway options"), ("pgp", ( (BooleanOption, "enable", "no", "Enable PGP processing. Requires pyme. If you're planning\n" diff -r dce3cfe7ec61 -r 8ea6d8eb2b14 roundup/mailgw.py --- a/roundup/mailgw.py Wed Feb 11 00:44:16 2015 +1100 +++ b/roundup/mailgw.py Fri Mar 18 16:18:20 2016 +0100 @@ -540,8 +540,12 @@ self.has_prefix = False self.matches = dict.fromkeys(['refwd', 'quote', 'classname', 'nodeid', 'title', 'args', 'argswhole']) - self.from_list = message.getaddrlist('resent-from') \ - or message.getaddrlist('from') + self.keep_real_from = self.config['EMAIL_KEEP_REAL_FROM'] + if self.keep_real_from: + self.from_list = message.getaddrlist('from') + else: + self.from_list = message.getaddrlist('resent-from') \ + or message.getaddrlist('from') self.pfxmode = self.config['MAILGW_SUBJECT_PREFIX_PARSING'] self.sfxmode = self.config['MAILGW_SUBJECT_SUFFIX_PARSING'] # these are filled in by subsequent parsing steps @@ -1469,7 +1473,7 @@ self.parsed_message = None crypt = False sendto = message.getaddrlist('resent-from') - if not sendto: + if not sendto or self.instance.config['EMAIL_KEEP_REAL_FROM']: sendto = message.getaddrlist('from') if not sendto: # very bad-looking message - we don't even know who sent it diff -r dce3cfe7ec61 -r 8ea6d8eb2b14 test/test_mailgw.py --- a/test/test_mailgw.py Wed Feb 11 00:44:16 2015 +1100 +++ b/test/test_mailgw.py Fri Mar 18 16:18:20 2016 +0100 @@ -2586,6 +2586,25 @@ self.assertEqual(l, [self.richard_id, self.mary_id]) return nodeid + def testResentFromSwitchedOff(self): + self.instance.config.EMAIL_KEEP_REAL_FROM = 'yes' + nodeid = self._handle_mail('''Content-Type: text/plain; + charset="iso-8859-1" +From: Chef +Resent-From: mary +To: issue_tracker@your.tracker.email.domain.example +Cc: richard@test.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.chef_id, self.richard_id]) + return nodeid + def testDejaVu(self): self.assertRaises(IgnoreLoop, self._handle_mail, '''Content-Type: text/plain;