From 46460547caf558d50040acc75b25373ea07fc83c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Apr 2021 07:41:35 +0200 Subject: [PATCH] Fix exception in markdown parser --- server/helpers/markdown.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/helpers/markdown.ts b/server/helpers/markdown.ts index 7c4a1a8b1..2126bb752 100644 --- a/server/helpers/markdown.ts +++ b/server/helpers/markdown.ts @@ -9,6 +9,8 @@ markdownIt.enable(TEXT_WITH_HTML_RULES) markdownIt.use(markdownItEmoji) const toSafeHtml = text => { + if (!text) return '' + // Restore line feed const textWithLineFeed = text.replace(//g, '\r\n') @@ -20,6 +22,8 @@ const toSafeHtml = text => { } const mdToPlainText = text => { + if (!text) return '' + // Convert possible markdown (emojis, emphasis and lists) to html const html = markdownIt.render(text)