From 795091c69d2bc40e3bd2b5ae29451ea3af07d908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 27 Oct 2023 16:50:46 +0200 Subject: [PATCH] [FIX] base: fix 'extract_rfc2822_addresses' in case of email-like name Remove quotes when name of a formatted email is also an email, as indicated in tests. We still get two emails being sent for a given outgoing email when the name part is an email but that would be difficult to avoid. Task-3566542 closes odoo/odoo#141856 X-original-commit: odoo/odoo@d3cdaa6c188155fa3377c43653e4e5dfe19f99ab Related: odoo/enterprise#50892 Signed-off-by: Thibault Delavallee (tde) --- addons/test_mail/tests/test_mail_composer.py | 4 ++-- odoo/addons/base/models/ir_mail_server.py | 2 +- odoo/addons/base/tests/test_mail.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/test_mail/tests/test_mail_composer.py b/addons/test_mail/tests/test_mail_composer.py index f683689ee04..92a3f198e74 100644 --- a/addons/test_mail/tests/test_mail_composer.py +++ b/addons/test_mail/tests/test_mail_composer.py @@ -1982,7 +1982,7 @@ class TestComposerResultsComment(TestMailComposer, CronMixinCase): ) # to check behavior of extract_rfc2822_addresses if recipient == new_partner: - smtp_to_list = ['"test.to.1@test.example.com"', 'test.to.1@test.example.com'] + smtp_to_list = ['test.to.1@test.example.com', 'test.to.1@test.example.com'] else: smtp_to_list = [recipient.email_normalized] if exp_alias_domain == self.mail_alias_domain: @@ -2788,7 +2788,7 @@ class TestComposerResultsMass(TestMailComposer): for recipient in recipients: # to check behavior of extract_rfc2822_addresses if recipient == new_partner: - smtp_to_list = ['"test.to.1@test.example.com"', 'test.to.1@test.example.com'] + smtp_to_list = ['test.to.1@test.example.com', 'test.to.1@test.example.com'] else: smtp_to_list = [recipient.email_normalized] if exp_alias_domain == self.mail_alias_domain: diff --git a/odoo/addons/base/models/ir_mail_server.py b/odoo/addons/base/models/ir_mail_server.py index 6f364ae88ab..3704a2c6fcb 100644 --- a/odoo/addons/base/models/ir_mail_server.py +++ b/odoo/addons/base/models/ir_mail_server.py @@ -64,7 +64,7 @@ smtplib.stderr = WriteToLogger() def is_ascii(s): return all(ord(cp) < 128 for cp in s) -address_pattern = re.compile(r'([^ ,<@]+@[^> ,]+)') +address_pattern = re.compile(r'([^" ,<@]+@[^>" ,]+)') def extract_rfc2822_addresses(text): """Returns a list of valid RFC2822 addresses diff --git a/odoo/addons/base/tests/test_mail.py b/odoo/addons/base/tests/test_mail.py index 77ac2950f27..26e36428b1e 100644 --- a/odoo/addons/base/tests/test_mail.py +++ b/odoo/addons/base/tests/test_mail.py @@ -763,9 +763,9 @@ class TestEmailTools(BaseCase): ('"Admin" , Demo ', ['admin@example.com']), ('admin@éxample.com', ['admin@xn--xample-9ua.com']), # formatted input containing email - ('"admin@éxample.com" ', ['admin@xn--xample-9ua.com']), + ('"admin@éxample.com" ', ['admin@xn--xample-9ua.com', 'admin@xn--xample-9ua.com']), ('"Robert Le Grand" ', ['robert@notgmail.com']), - ('"robert@notgmail.com" ', ['"robert@notgmail.com"', 'robert@notgmail.com']), + ('"robert@notgmail.com" ', ['robert@notgmail.com', 'robert@notgmail.com']), # accents ('DéBoulonneur@examplé.com', ['DéBoulonneur@xn--exampl-gva.com']), ]