Skip to content

Commit 3b118b8

Browse files
committed
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.
1 parent cf437b0 commit 3b118b8

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

CHANGES.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ and template changes not listed here.
66
Each entry has the developer who committed the change in brackets.
77
Entries without name were done by Richard Jones.
88

9-
**IMPORTANT** The v1.5.x releases of Roundup will be the last to support
10-
Python v2.5. Support for Python v2.5 will be dropped with the v1.6
11-
release of Roundup, at which point users will need to run Roundup using
12-
either Python v2.6 or v2.7.
9+
**IMPORTANT** The v1.5.x releases of Roundup were the last to support
10+
Python v2.5. Support for Python v2.5 is dropped starting with the v1.6.x
11+
releases of Roundup, at which point either Python v2.6 or v2.7 is
12+
required to run those releases of Roundup.
1313

1414

1515
201?-??-??: 1.6.0
@@ -20,7 +20,10 @@ Features:
2020

2121
Fixed
2222

23-
- (none yet)
23+
- issue1615201: Optionally restore the original (version 0.6) mailgw
24+
behaviour of ignoring a Resent-From:-header and using the real
25+
From-header instead: new configuration option EMAIL_KEEP_REAL_FROM
26+
(Peter Funk aka Pefu).
2427

2528

2629
2016-01-11: 1.5.1

doc/user_guide.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,10 @@ the message may be added to the `nosy list`_ depending on:
549549
creates a new issue. If 'yes', then the recipients will be added on
550550
followups too. If 'no', they're never added to the nosy.
551551

552+
Some organisations might prefer to have someone moderate emails before
553+
they are delivered into Roundup. Those might want to set the
554+
configuration option ``EMAIL_KEEP_REAL_FROM`` to ``'yes'`` to avoid
555+
having the moderators address appearing as the creator of issues.
552556

553557
Nosy List
554558
~~~~~~~~~

roundup/configuration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,13 @@ def str2value(self, value):
818818
"multipart/alternative, and this option is set, all other\n"
819819
"parts of the multipart/alternative are ignored. The default\n"
820820
"is to keep all parts and attach them to the issue."),
821-
), "Roundup Mail Gateway options"),
821+
(BooleanOption, "keep_real_from", "no",
822+
"When handling emails ignore the Resent-From:-header\n"
823+
"and use the original senders From:-header instead.\n"
824+
"(This might be desirable in some situations where a moderator\n"
825+
"reads incoming messages first before bouncing them to Roundup)",
826+
["EMAIL_KEEP_REAL_FROM"]),
827+
), "Roundup Mail Gateway options"),
822828
("pgp", (
823829
(BooleanOption, "enable", "no",
824830
"Enable PGP processing. Requires pyme. If you're planning\n"

roundup/mailgw.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,12 @@ def __init__(self, mailgw, message):
540540
self.has_prefix = False
541541
self.matches = dict.fromkeys(['refwd', 'quote', 'classname',
542542
'nodeid', 'title', 'args', 'argswhole'])
543-
self.from_list = message.getaddrlist('resent-from') \
544-
or message.getaddrlist('from')
543+
self.keep_real_from = self.config['EMAIL_KEEP_REAL_FROM']
544+
if self.keep_real_from:
545+
self.from_list = message.getaddrlist('from')
546+
else:
547+
self.from_list = message.getaddrlist('resent-from') \
548+
or message.getaddrlist('from')
545549
self.pfxmode = self.config['MAILGW_SUBJECT_PREFIX_PARSING']
546550
self.sfxmode = self.config['MAILGW_SUBJECT_SUFFIX_PARSING']
547551
# these are filled in by subsequent parsing steps
@@ -1469,7 +1473,7 @@ def handle_Message(self, message):
14691473
self.parsed_message = None
14701474
crypt = False
14711475
sendto = message.getaddrlist('resent-from')
1472-
if not sendto:
1476+
if not sendto or self.instance.config['EMAIL_KEEP_REAL_FROM']:
14731477
sendto = message.getaddrlist('from')
14741478
if not sendto:
14751479
# very bad-looking message - we don't even know who sent it

test/test_mailgw.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,6 +2586,25 @@ def testResentFrom(self):
25862586
self.assertEqual(l, [self.richard_id, self.mary_id])
25872587
return nodeid
25882588

2589+
def testResentFromSwitchedOff(self):
2590+
self.instance.config.EMAIL_KEEP_REAL_FROM = 'yes'
2591+
nodeid = self._handle_mail('''Content-Type: text/plain;
2592+
charset="iso-8859-1"
2593+
From: Chef <[email protected]>
2594+
Resent-From: mary <[email protected]>
2595+
2596+
2597+
Message-Id: <dummy_test_message_id>
2598+
Subject: [issue] Testing...
2599+
2600+
This is a test submission of a new issue.
2601+
''')
2602+
assert not os.path.exists(SENDMAILDEBUG)
2603+
l = self.db.issue.get(nodeid, 'nosy')
2604+
l.sort()
2605+
self.assertEqual(l, [self.chef_id, self.richard_id])
2606+
return nodeid
2607+
25892608
def testDejaVu(self):
25902609
self.assertRaises(IgnoreLoop, self._handle_mail,
25912610
'''Content-Type: text/plain;

0 commit comments

Comments
 (0)