From 42aff92a4e1cb35af3ee90817dccc3548761d4a8 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Wed, 30 May 2018 14:06:54 +0200 Subject: [PATCH] [FIX] account, purchase, sale: properly quote the name of the email sender MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit formataddr (from the email python library) writes email_from as '"name" ' in the email_from field of the mail.compose.message record. When the mail is rendered, onchange_template_id is triggered. This then overwrites the values of email_from among other fields. What happens is that it uses the email_from field from the template to render the email_from, bypassing what was put by formataddr before. What happens in some cases is that it is rendered as 'name ' (note the quotes have been stripped away). If name contains arbitrary symbols, e.g. name = 'pépé [company] , ohlala', then getaddresses which is supposed to parse the (name, email) pairs gets thrown off (in particular, will be interpreted as an email address, and many other problems with the various special symbols). It then gives these wrong elements as email addresses, which will usually crash when getting non-ascii symbols (i.e. these strings don't respect the relevant RFC for email addresses). Closes: https://github.com/odoo/odoo/issues/23502 https://github.com/odoo/odoo/pull/2311823118 opw 815202 opw 1824243 --- addons/account/data/mail_template_data.xml | 2 +- addons/purchase/data/mail_template_data.xml | 4 ++-- addons/sale/data/mail_template_data.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/data/mail_template_data.xml b/addons/account/data/mail_template_data.xml index 25d54c81c85..944115b47c1 100644 --- a/addons/account/data/mail_template_data.xml +++ b/addons/account/data/mail_template_data.xml @@ -7,7 +7,7 @@ Invoicing: Invoice email - ${(object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '')|safe} + ${(object.user_id.email and '"%s" <%s>' % (object.user_id.name, object.user_id.email) or '')|safe} ${object.company_id.name} Invoice (Ref ${object.number or 'n/a'}) ${object.partner_id.id} diff --git a/addons/purchase/data/mail_template_data.xml b/addons/purchase/data/mail_template_data.xml index aa2f852a9ac..ceb19ec9763 100644 --- a/addons/purchase/data/mail_template_data.xml +++ b/addons/purchase/data/mail_template_data.xml @@ -5,7 +5,7 @@ RFQ - Send by Email - ${(object.create_uid.email and '%s <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} + ${(object.create_uid.email and '"%s" <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} ${object.company_id.name} Order (Ref ${object.name or 'n/a' }) ${object.partner_id.id} @@ -46,7 +46,7 @@ from ${object.company_id.name}. Purchase Order - Send by Email - ${(object.create_uid.email and '%s <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} + ${(object.create_uid.email and '"%s" <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} ${object.company_id.name} Order (Ref ${object.name or 'n/a' }) ${object.partner_id.id} diff --git a/addons/sale/data/mail_template_data.xml b/addons/sale/data/mail_template_data.xml index 1a584b765f5..5e46baeec0f 100644 --- a/addons/sale/data/mail_template_data.xml +++ b/addons/sale/data/mail_template_data.xml @@ -5,7 +5,7 @@ Sales Order - Send by Email - ${(object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '')|safe} + ${(object.user_id.email and '"%s" <%s>' % (object.user_id.name, object.user_id.email) or '')|safe} ${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' }) ${object.partner_id.id}