From a103d4a43effd815e51de02804d6588580ce62f3 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 16 Nov 2018 16:35:22 +0100 Subject: [PATCH] [FIX] mail: use strict email matching for bounces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a bounce is received, we look for matching partners in order to increment the bounce counter. However by using [`ilike','email`] we carry the risk of matching emails that contain the bounce email: ['email', 'ilike', 'john@hitmail.com“] will also match 'random.john@hitmail.com' for example. Using strict equality is safer, and the worst that can happen is that we fail to count one bounce. --- 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 5082fc981a7..bd538fe7a39 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1171,7 +1171,7 @@ class MailThread(models.AbstractModel): final_recipient_data = tools.decode_message_header(dsn, 'Final-Recipient') partner_address = final_recipient_data.split(';', 1)[1].strip() if partner_address: - partners = partners.sudo().search([('email', 'like', partner_address)]) + partners = partners.sudo().search([('email', '=', partner_address)]) for partner in partners: partner.message_receive_bounce(partner_address, partner, mail_id=bounced_mail_id)