diff options
author | Mark Sapiro <mark@msapiro.net> | 2014-04-23 20:30:50 -0700 |
---|---|---|
committer | Mark Sapiro <mark@msapiro.net> | 2014-04-23 20:30:50 -0700 |
commit | e700b13082fa55f9172c04fba6366a4a3e859ff5 (patch) | |
tree | affb5438f9fa2dc72e3aaba9bf79f4ea49dbae18 /Mailman/Handlers/CookHeaders.py | |
parent | ec813e77dcffc14e02331ecd65d5e3f6b7019ad5 (diff) | |
download | mailman2-e700b13082fa55f9172c04fba6366a4a3e859ff5.tar.gz mailman2-e700b13082fa55f9172c04fba6366a4a3e859ff5.tar.xz mailman2-e700b13082fa55f9172c04fba6366a4a3e859ff5.zip |
Fixed the Munge From action to not actually Munge the From: or Reply-To:
until after the message has been sent to the archive, digest and usenet
gateway.
Diffstat (limited to 'Mailman/Handlers/CookHeaders.py')
-rwxr-xr-x | Mailman/Handlers/CookHeaders.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py index 83f278b4..9f94bd4a 100755 --- a/Mailman/Handlers/CookHeaders.py +++ b/Mailman/Handlers/CookHeaders.py @@ -68,7 +68,7 @@ def change_header(name, value, mlist, msg, msgdata, delete=True, repl=True): if ((msgdata.get('from_is_list') == 2 or (msgdata.get('from_is_list') == 0 and mlist.from_is_list == 2)) and not msgdata.get('_fasttrack') - ): + ) or name.lower() in ('from', 'reply-to'): msgdata.setdefault('add_header', {})[name] = value elif repl or not msg.has_key(name): if delete: @@ -128,16 +128,8 @@ def process(mlist, msg, msgdata): realname = email # Remove domain from realname if it looks like an email address realname = re.sub(r'@([^ .]+\.)+[^ .]+$', '---', realname) - replies = getaddresses(msg.get('reply-to', '')) - reply_addrs = [x[1].lower() for x in replies] - if reply_addrs: - if email.lower() not in reply_addrs: - rt = msg['reply-to'] + ', ' + msg['from'] - else: - rt = msg['reply-to'] - else: - rt = msg['from'] - change_header('Reply-To', rt, mlist, msg, msgdata) + # Remember the original From: here for adding to Reply-To: below. + o_from = parseaddr(msg['from']) change_header('From', formataddr(('%s via %s' % (realname, mlist.real_name), mlist.GetListEmail())), @@ -145,6 +137,9 @@ def process(mlist, msg, msgdata): if mlist.from_is_list != 2: del msg['sender'] #MAS ?? mlist.include_sender_header = 0 + else: + # Use this as a flag + o_from = None # Reply-To: munging. Do not do this if the message is "fast tracked", # meaning it is internally crafted and delivered to a specific user. BAW: # Yuck, I really hate this feature but I've caved under the sheer pressure @@ -171,9 +166,18 @@ def process(mlist, msg, msgdata): # cases we'll zap the existing field because RFC 2822 says max one is # allowed. if not mlist.first_strip_reply_to: + # If we Munged the From:, add it to Reply-To: if we're not + # stripping it. + #MAS ? Should we add it anyway? + if o_from: + add(o_from) orig = msg.get_all('reply-to', []) for pair in getaddresses(orig): add(pair) + # We also need to put the old From: in Reply-To: if reply_goes_to_list + # is to the poster even if we're stripping Reply-To: + if mlist.reply_goes_to_list == 0 and o_from: + add(o_from) # Set Reply-To: header to point back to this list. Add this last # because some folks think that some MUAs make it easier to delete # addresses from the right than from the left. |