[FIX] mail.thread.route: safer parsing of envelope headers, courtesy of Jordi Llonch
authorOlivier Dony <odo@openerp.com>
Tue, 18 Dec 2012 12:29:35 +0000 (13:29 +0100)
committerOlivier Dony <odo@openerp.com>
Tue, 18 Dec 2012 12:29:35 +0000 (13:29 +0100)
The Delivered-To cannot be considered
exclusively authoritative, as it is
commonly overwritten due to virtual
routes during mail delivery.
Its primary purpose is to avoid mail
loops, so it cannot be fully trusted
here.

lp bug: https://launchpad.net/bugs/1085488 fixed

bzr revid: odo@openerp.com-20121218122935-vbcld3vrl260z96m

addons/mail/mail_thread.py

index 76e0a57..fc2a554 100644 (file)
@@ -338,8 +338,9 @@ class mail_thread(osv.AbstractModel):
         # 2. Look for a matching mail.alias entry
         # Delivered-To is a safe bet in most modern MTAs, but we have to fallback on To + Cc values
         # for all the odd MTAs out there, as there is no standard header for the envelope's `rcpt_to` value.
-        rcpt_tos = decode_header(message, 'Delivered-To') or \
-             ','.join([decode_header(message, 'To'),
+        rcpt_tos = \
+             ','.join([decode_header(message, 'Delivered-To'),
+                       decode_header(message, 'To'),
                        decode_header(message, 'Cc'),
                        decode_header(message, 'Resent-To'),
                        decode_header(message, 'Resent-Cc')])