[MERGE] Forward-port saas-4 up to 8b15482
[odoo/odoo.git] / addons / mail / mail_thread.py
index d04221c..23c3255 100644 (file)
@@ -906,7 +906,7 @@ class mail_thread(osv.AbstractModel):
 
         # 1. message is a reply to an existing message (exact match of message_id)
         ref_match = thread_references and tools.reference_re.search(thread_references)
-        msg_references = thread_references.split()
+        msg_references = mail_header_msgid_re.findall(thread_references)
         mail_message_ids = mail_msg_obj.search(cr, uid, [('message_id', 'in', msg_references)], context=context)
         if ref_match and mail_message_ids:
             original_msg = mail_msg_obj.browse(cr, SUPERUSER_ID, mail_message_ids[0], context=context)
@@ -949,7 +949,7 @@ class mail_thread(osv.AbstractModel):
                                 email_from, email_to, message_id, model, thread_id, custom_values, uid)
                             return [route]
 
-        # 2. Reply to a private message
+        # 3. Reply to a private message
         if in_reply_to:
             mail_message_ids = mail_msg_obj.search(cr, uid, [
                                 ('message_id', '=', in_reply_to),
@@ -966,7 +966,7 @@ class mail_thread(osv.AbstractModel):
                         email_from, email_to, message_id, mail_message.id, custom_values, uid)
                     return [route]
 
-        # 3. Look for a matching mail.alias entry
+        # 4. 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 = \
@@ -1001,7 +1001,7 @@ class mail_thread(osv.AbstractModel):
                         routes.append(route)
                 return routes
 
-        # 4. Fallback to the provided parameters, if they work
+        # 5. Fallback to the provided parameters, if they work
         if not thread_id:
             # Legacy: fallback to matching [ID] in the Subject
             match = tools.res_re.search(decode_header(message, 'Subject'))