From 2fc46a064d36d9de2c6debf9582976f938e3568b Mon Sep 17 00:00:00 2001 From: Abridbus Date: Tue, 13 Aug 2019 09:00:35 +0000 Subject: [PATCH] [FIX] mail: removing whitespace on message_id from incoming mail Because of a whitespace character present at the beginning of the message_id of some mails, they were fetched twice. From the SQL side, we see that Outlook is formatting the header following the RFC822 by allowing the header to look like: Header: From RFC822: "Each header field can be viewed as a single, logical line of ASCII characters. For convenience, the field-body portion of this conceptual entity can be split into a multiple-line representation" (abr.) It was also possible to find out by checking the logs. One or two whitespace(s) can be seen before the hash of the msg_id. The following commit is making sure we use and save the message_id without the whitespace by stripping them off on the coming mail. OPW-2006806 Applying CHS solution to avoid crash on empty header. closes odoo/odoo#35682 Signed-off-by: bve-odoo --- addons/mail/models/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 9de945ece86..25c01b723d9 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1500,7 +1500,7 @@ class MailThread(models.AbstractModel): # Very unusual situation, be we should be fault-tolerant here message_id = "<%s@localhost>" % time.time() _logger.debug('Parsing Message without message-id, generating a random one: %s', message_id) - msg_dict['message_id'] = message_id + msg_dict['message_id'] = message_id.strip() if message.get('Subject'): msg_dict['subject'] = tools.decode_smtp_header(message.get('Subject'))