From d0cf08aa57d9a2b83b6418f5eab6d8a7ea6e7454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 16 Aug 2019 15:26:59 +0000 Subject: [PATCH] [FIX] portal: prevent crash on chatter post if no attachment given Follow up of 3620cb68a0190031d3e1a963d8554834ab7f192b `split` called on an empty string returns a list containing the empty string. The previous commit assumed it was returning an empty list. closes odoo/odoo#35773 Signed-off-by: Christophe Simonis --- addons/portal/controllers/mail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/portal/controllers/mail.py b/addons/portal/controllers/mail.py index f06f14a1b56..1f776bb6ab1 100644 --- a/addons/portal/controllers/mail.py +++ b/addons/portal/controllers/mail.py @@ -98,8 +98,8 @@ class PortalChatter(http.Controller): res_id = int(res_id) - attachment_ids = [int(res_id) for res_id in attachment_ids.split(',')] - attachment_tokens = attachment_tokens.split(',') + attachment_ids = [int(attachment_id) for attachment_id in attachment_ids.split(',') if attachment_id] + attachment_tokens = [attachment_token for attachment_token in attachment_tokens.split(',') if attachment_token] if len(attachment_tokens) != len(attachment_ids): raise UserError(_("An access token must be provided for each attachment.")) for (attachment_id, access_token) in zip(attachment_ids, attachment_tokens):