Skip to content

Commit

Permalink
[FIX] portal: prevent crash on chatter post if no attachment given
Browse files Browse the repository at this point in the history
Follow up of 3620cb6

`split` called on an empty string returns a list containing the empty string.
The previous commit assumed it was returning an empty list.

closes #35773

Signed-off-by: Christophe Simonis <chs@odoo.com>
  • Loading branch information
seb-odoo committed Aug 16, 2019
1 parent 9a0fedf commit d0cf08a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/portal/controllers/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def portal_chatter_post(self, res_model, res_id, message, redirect=None, attachm

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):
Expand Down

0 comments on commit d0cf08a

Please sign in to comment.