summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_mail_mail.py
diff options
context:
space:
mode:
authorJulien (juc) Castiaux <juc@odoo.com>2018-10-15 13:28:15 +0000
committerJulien (juc) Castiaux <juc@odoo.com>2018-10-15 13:42:58 +0000
commit71f188082fff062a708a68e799ca1f3000fa21fb (patch)
tree4aeeb6115ef26b977ebca7b1007d190f8308d995 /addons/test_mail/tests/test_mail_mail.py
parent661483c026777fff4c6dd6ec245c991f7c4248ac (diff)
[FIX] mail: unicode character in email cannot be parsed
Sending email to addresses containing unicode characters cannot be parsed by python and result in a UnicodeEncodeError. This PR catch that specific exception and output a meaningful error message. Decision has been taken to not trigger any error message client-side has it would have needed modifications on some sensitive low-level backend code. To reproduce: - Configure odoo so it uses an email server - Send an invoice to a partner whoose email address contains some unicode characters (exemple: æøåÇÀ@example.com) opw-1892409 closes odoo/odoo#27804
Diffstat (limited to 'addons/test_mail/tests/test_mail_mail.py')
-rw-r--r--addons/test_mail/tests/test_mail_mail.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/addons/test_mail/tests/test_mail_mail.py b/addons/test_mail/tests/test_mail_mail.py
index eeeb22a296f..4debd669874 100644
--- a/addons/test_mail/tests/test_mail_mail.py
+++ b/addons/test_mail/tests/test_mail_mail.py
@@ -6,6 +6,7 @@ import itertools
from odoo.addons.test_mail.tests import common as mail_common
from odoo.tests import common
from odoo.tools import mute_logger
+from odoo.addons.base.models.ir_mail_server import MailDeliveryException
class TestMail(common.SavepointCase, mail_common.MockEmails):
@@ -43,3 +44,13 @@ class TestMail(common.SavepointCase, mail_common.MockEmails):
self.email_to_list.extend(itertools.chain.from_iterable(sent_email['email_to'] for sent_email in self._mails if sent_email.get('email_to')))
self.assertNotIn(u'Ernest Employee <e.e@example.com>', self.email_to_list)
self.assertIn(u'test@example.com', self.email_to_list)
+
+ @mute_logger('odoo.addons.mail.models.mail_mail')
+ def test_mail_message_values_unicode(self):
+ mail = self.env['mail.mail'].create({
+ 'body_html': '<p>Test</p>',
+ 'email_to': 'test.😊@example.com',
+ 'partner_ids': [(4, self.user_employee.partner_id.id)]
+ })
+
+ self.assertRaises(MailDeliveryException, mail.send)