fix: decode numerically encoded html entities in text

This commit is contained in:
Daniel Roe 2022-12-05 00:15:17 +00:00
parent 408aff20ee
commit 4146915a33
No known key found for this signature in database
GPG key ID: 22D5008E4F5D9B55
2 changed files with 5 additions and 3 deletions

View file

@ -72,7 +72,9 @@ export function parseMastodonHTML(html: string, customEmojis: Record<string, Emo
[/\*(.*?)\*/g, '<em>$1</em>'],
[/~~(.*?)~~/g, '<del>$1</del>'],
[/`([^`]+?)`/g, '<code>$1</code>'],
] as const
[/&#(\d+);/g, (_: string, dec: string) => String.fromCharCode(Number(dec))],
] as any
for (const [re, replacement] of replacements) {
for (const match of node.value.matchAll(re)) {
if (node.loc) {