summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-01-20 12:43:14 +0000
committerSébastien Theys <seb@odoo.com>2020-01-21 18:37:07 +0000
commitdf18a701f353f27d8ffa8df77f9576d1615f1097 (patch)
treeb8cdbde79d64883d7e89b6c9d1b1f66cb2d3dd03 /addons
parent194ed76c5cc932da1816076d7023e223ee5fae34 (diff)
[FIX] website_mail_channel: prevent crash in python3 email lib
`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#43698 X-original-commit: 7e5a7245e86d8a3bcdab83c740cb4d188d009a40 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/website_mail_channel/models/mail_channel.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/addons/website_mail_channel/models/mail_channel.py b/addons/website_mail_channel/models/mail_channel.py
index 6778a11f4a2..3f342878330 100644
--- a/addons/website_mail_channel/models/mail_channel.py
+++ b/addons/website_mail_channel/models/mail_channel.py
@@ -5,8 +5,7 @@ import hmac
from werkzeug import urls
-from odoo import api, models
-from odoo.tools.safe_eval import safe_eval
+from odoo import models
from odoo.addons.http_routing.models.ir_http import slug
@@ -16,9 +15,9 @@ class MailGroup(models.Model):
def _notify_email_header_dict(self):
headers = super(MailGroup, self)._notify_email_header_dict()
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,)
return headers
def _send_confirmation_email(self, partner_ids, unsubscribe=False):