aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-16 07:41:35 +0200
committerChocobozzz <me@florianbigard.com>2021-04-16 07:41:35 +0200
commit46460547caf558d50040acc75b25373ea07fc83c (patch)
tree355d872757cf2b744f4291a1c9a715467a83ac3a
parent205e4f56f3da1f787f1bc2cdfcc39948a99a16b1 (diff)
downloadPeerTube-46460547caf558d50040acc75b25373ea07fc83c.tar.gz
PeerTube-46460547caf558d50040acc75b25373ea07fc83c.tar.zst
PeerTube-46460547caf558d50040acc75b25373ea07fc83c.zip
Fix exception in markdown parser
-rw-r--r--server/helpers/markdown.ts4
1 files changed, 4 insertions, 0 deletions
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)
9markdownIt.use(markdownItEmoji) 9markdownIt.use(markdownItEmoji)
10 10
11const toSafeHtml = text => { 11const toSafeHtml = text => {
12 if (!text) return ''
13
12 // Restore line feed 14 // Restore line feed
13 const textWithLineFeed = text.replace(/<br.?\/?>/g, '\r\n') 15 const textWithLineFeed = text.replace(/<br.?\/?>/g, '\r\n')
14 16
@@ -20,6 +22,8 @@ const toSafeHtml = text => {
20} 22}
21 23
22const mdToPlainText = text => { 24const mdToPlainText = text => {
25 if (!text) return ''
26
23 // Convert possible markdown (emojis, emphasis and lists) to html 27 // Convert possible markdown (emojis, emphasis and lists) to html
24 const html = markdownIt.render(text) 28 const html = markdownIt.render(text)
25 29