From 09290b112ee181f4acad73983aaf5a6528d76072 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 5 Dec 2022 00:30:20 +0000 Subject: [PATCH] fix: decode other entity text as well --- composables/content.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composables/content.ts b/composables/content.ts index 97c66e9c..76a18b84 100644 --- a/composables/content.ts +++ b/composables/content.ts @@ -43,6 +43,12 @@ function handleNode(el: Node) { return handleCodeBlock(el) || handleMention(el) || el } +const decoder = document.createElement('textarea') +function decode(text: string) { + decoder.innerHTML = text + return decoder.value +} + /** * Parse raw HTML form Mastodon server to AST, * with interop of custom emojis and inline Markdown syntax @@ -72,7 +78,7 @@ export function parseMastodonHTML(html: string, customEmojis: Record$1'], [/~~(.*?)~~/g, '$1'], [/`([^`]+?)`/g, '$1'], - [/&#(\d+);/g, (_: string, dec: string) => String.fromCharCode(Number(dec))], + [/&[^;]+;/g, (val: string) => decode(val)], ] as any for (const [re, replacement] of replacements) {