From 9cb13a91cd889320f5044c1921d9a48c1d6a2091 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Fri, 25 Mar 2022 10:37:35 +0530 Subject: [PATCH] Fix incorrect custom html crashing app (#429) Signed-off-by: Ajay Bura --- src/app/molecules/message/Message.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/molecules/message/Message.jsx b/src/app/molecules/message/Message.jsx index f5e3e2b..5a906f0 100644 --- a/src/app/molecules/message/Message.jsx +++ b/src/app/molecules/message/Message.jsx @@ -186,9 +186,17 @@ const MessageBody = React.memo(({ // if body is not string it is a React element. if (typeof body !== 'string') return
{body}
; - let content = isCustomHTML - ? twemojify(sanitizeCustomHtml(body), undefined, true, false) - : twemojify(body, undefined, true); + let content = null; + if (isCustomHTML) { + try { + content = twemojify(sanitizeCustomHtml(body), undefined, true, false); + } catch { + console.error('Malformed custom html: ', body); + content = twemojify(body, undefined); + } + } else { + content = twemojify(body, undefined, true); + } // Determine if this message should render with large emojis // Criteria: