aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/Handlers/CookHeaders.py
diff options
context:
space:
mode:
authorMark Sapiro <mark@msapiro.net>2014-05-09 12:19:29 -0700
committerMark Sapiro <mark@msapiro.net>2014-05-09 12:19:29 -0700
commit307a5e4da3877c944be296b278ab59b7c70e24b7 (patch)
tree05a077bf79574ed921a5b6fe5b64253ae98f95d2 /Mailman/Handlers/CookHeaders.py
parentf3b2c2c7523b5962164672b5b5889c2eb85aca0a (diff)
downloadmailman2-307a5e4da3877c944be296b278ab59b7c70e24b7.tar.gz
mailman2-307a5e4da3877c944be296b278ab59b7c70e24b7.tar.xz
mailman2-307a5e4da3877c944be296b278ab59b7c70e24b7.zip
Handle missing From: header addresses for DMARC mitigation actions.
(LP: #1318025)
Diffstat (limited to 'Mailman/Handlers/CookHeaders.py')
-rwxr-xr-xMailman/Handlers/CookHeaders.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py
index c6f25044..78701850 100755
--- a/Mailman/Handlers/CookHeaders.py
+++ b/Mailman/Handlers/CookHeaders.py
@@ -120,7 +120,16 @@ def process(mlist, msg, msgdata):
mlist, msg, msgdata, repl=False)
# Do we change the from so the list takes ownership of the email
if (msgdata.get('from_is_list') or mlist.from_is_list) and not fasttrack:
- realname, email = parseaddr(msg['from'])
+ # Be as robust as possible here.
+ faddrs = getaddresses(msg.get_all('from', []))
+ if len(faddrs) == 1:
+ realname, email = o_from = faddrs[0]
+ else:
+ # No From: or multiple addresses. Just punt and take
+ # the get_sender result.
+ realname = ''
+ email = msgdata['original_sender']
+ o_from = (realname, email)
if not realname:
if mlist.isMember(email):
realname = mlist.getMemberName(email) or email
@@ -128,8 +137,6 @@ def process(mlist, msg, msgdata):
realname = email
# Remove domain from realname if it looks like an email address
realname = re.sub(r'@([^ .]+\.)+[^ .]+$', '---', realname)
- # 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())),