From 3d35a5d42b419dfbf30da4f365610b31d92cbef2 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Quenot Date: Thu, 24 Jul 2014 15:37:18 +0200 Subject: [PATCH] [FIX] mail: Strip In-Reply-To header For emails sent via Office 365, reply-to header could contains additional spaces or get multiline header. e.g.: In-Reply-To: <4ba8f246904b4fedb49fbab7945a7f82@AM3PR06MB433.eurprd06.prod.outl$$k.com> The message lookup fails if header is not stripped --- addons/mail/mail_thread.py | 2 +- addons/mail/tests/test_mail_gateway.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 509c097496c..0dcfc6d5f68 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -554,7 +554,7 @@ class mail_thread(osv.AbstractModel): email_from = decode_header(message, 'From') email_to = decode_header(message, 'To') references = decode_header(message, 'References') - in_reply_to = decode_header(message, 'In-Reply-To') + in_reply_to = decode_header(message, 'In-Reply-To').strip() # 1. Verify if this is a reply to an existing thread thread_references = references or in_reply_to diff --git a/addons/mail/tests/test_mail_gateway.py b/addons/mail/tests/test_mail_gateway.py index fcb1890cdad..5bfebebfc95 100644 --- a/addons/mail/tests/test_mail_gateway.py +++ b/addons/mail/tests/test_mail_gateway.py @@ -533,7 +533,7 @@ class TestMailgateway(TestMailBase): # 1. In-Reply-To header reply_msg2 = format(MAIL_TEMPLATE, to='erroneous@example.com', - extra='In-Reply-To: %s' % msg1.message_id, + extra='In-Reply-To:\r\n\t%s' % msg1.message_id, msg_id='<1198923581.41972151344608186760.JavaMail.3@agrolait.com>') self.mail_group.message_process(cr, uid, None, reply_msg2)