From 3bda53a791e25bc710915015e581fd3cdc2bc1ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Theys?= <seb@odoo.com>
Date: Mon, 20 Jan 2020 12:43:14 +0000
Subject: [PATCH] [FIX] website_mail_channel: prevent crash in python3 email
 lib
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

`AttributeError: 'tuple' object has no attribute 'startswith'`

When given headers that are tuples. They are expected to be string, as per [1].
The issue was introduced with [2], indeed the code was moved from inside a dict
where `,` was the usual dict separator to outside of a dict where `,` at the end
made them tuples.

To reproduce the issue, run the `test_mail` suite after having
`website_mail_channel` installed.

Issue highlighted as part of task-2178641

[1] https://docs.python.org/3/library/email.policy.html#email.policy.Policy.header_store_parse
[2] cae1c3977ff2777dcb77e4c2a51deb72ee57db22

closes odoo/odoo#43675

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
---
 addons/website_mail_channel/models/mail_channel.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/addons/website_mail_channel/models/mail_channel.py b/addons/website_mail_channel/models/mail_channel.py
index 108127b2bb44..17df0ddbf762 100644
--- a/addons/website_mail_channel/models/mail_channel.py
+++ b/addons/website_mail_channel/models/mail_channel.py
@@ -21,9 +21,9 @@ class MailGroup(models.Model):
         except Exception:
             headers = {}
         base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
-        headers['List-Archive'] = '<%s/groups/%s>' % (base_url, slug(self)),
-        headers['List-Subscribe'] = '<%s/groups>' % (base_url),
-        headers['List-Unsubscribe'] = '<%s/groups?unsubscribe>' % (base_url,),
+        headers['List-Archive'] = '<%s/groups/%s>' % (base_url, slug(self))
+        headers['List-Subscribe'] = '<%s/groups>' % (base_url)
+        headers['List-Unsubscribe'] = '<%s/groups?unsubscribe>' % (base_url,)
         res['headers'] = repr(headers)
         return res
 
-- 
GitLab