summaryrefslogtreecommitdiff
path: root/addons/test_mail
diff options
context:
space:
mode:
authorVeronika Kotovich <veronika.kotovich@gmail.com>2020-03-14 14:30:51 +0000
committerJulien Castiaux <juc@odoo.com>2021-03-18 11:11:22 +0000
commit402009b6c5082d949e433b8c8cbadb7012174865 (patch)
treef4e566e48e115daac8f6c263ac91d5e92fc44d1c /addons/test_mail
parentb738068be53621b23d9f19befdfdef50534ef434 (diff)
[FIX] mail: prepare mail header References to avoid line breaks
When Odoo routes incoming emails it is looking for existing messages in database using Message Ids which are coming from e-mail header References. In Odoo the message id looks pretty long like 743570479975566.1584086032.522504091262817-openerp-message-notify@ip-172-31-45-160 As it declared in [RFC2822] long header bodies can be "folded" using CRLF+WSP. And some mail clients do that very thing. They split References header body which contains Message Ids by "\n ". The example of mail client where it can be reproduced is apps.rackspace.com We created Sales Order in Odoo, sent this quotation to the client email. He replied with e-mail, and this email can't be matched with any existing message id and as result it's not attached to the Sales Order. RFC2882: https://tools.ietf.org/html/rfc2822#section-2.2.3 closes odoo/odoo#68069 X-original-commit: 559f6cf62711ad45557eddec3af7c66616724eb5 Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
Diffstat (limited to 'addons/test_mail')
-rw-r--r--addons/test_mail/tests/test_mail_gateway.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/addons/test_mail/tests/test_mail_gateway.py b/addons/test_mail/tests/test_mail_gateway.py
index d3e829248c2..cb5547efdd3 100644
--- a/addons/test_mail/tests/test_mail_gateway.py
+++ b/addons/test_mail/tests/test_mail_gateway.py
@@ -932,6 +932,27 @@ class TestMailgateway(TestMailCommon):
self.assertEqual(self.fake_email.child_ids, self.test_record.message_ids[0])
@mute_logger('odoo.addons.mail.models.mail_thread')
+ def test_message_process_references_external_buggy_message_id(self):
+ """
+ Incoming email being a reply to an external email processed by
+ odoo should update thread accordingly. Special case when the
+ external mail service wrongly folds the message_id on several
+ lines.
+ """
+ new_message_id = '<ThisIsTooMuchFake.MonsterEmail.789@agrolait.com>'
+ buggy_message_id = new_message_id.replace('MonsterEmail', 'Monster\r\n Email')
+ self.fake_email.write({
+ 'message_id': new_message_id
+ })
+ init_msg_count = len(self.test_record.message_ids)
+ self.format_and_process(
+ MAIL_TEMPLATE, self.email_from, 'erroneous@test.com',
+ extra='References: <2233@a.com>\r\n\t<3edss_dsa@b.com> %s' % buggy_message_id)
+
+ self.assertEqual(len(self.test_record.message_ids), init_msg_count + 1)
+ self.assertEqual(self.fake_email.child_ids, self.test_record.message_ids[0])
+
+ @mute_logger('odoo.addons.mail.models.mail_thread')
def test_message_process_references_forward(self):
""" Incoming email using references but with alias forward should not go into references destination """
self.env['mail.alias'].create({