From 6441ff45a905a0a78c537debc5c109bd46f58b3d Mon Sep 17 00:00:00 2001
From: Sol Fisher Romanoff <sol@solfisher.com>
Date: Tue, 2 Aug 2022 12:37:18 +0300
Subject: [PATCH] Decode html-encoded characters inside pre tags

---
 src/components/rich_content/rich_content.jsx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx
index 0c1e2c0c..0d553485 100644
--- a/src/components/rich_content/rich_content.jsx
+++ b/src/components/rich_content/rich_content.jsx
@@ -124,11 +124,18 @@ export default {
     }
 
     const renderMisskeyMarkdown = (content) => {
-      // Untangle code blocks from <br> tags
+      // Untangle code blocks from <br> tags and other html encodings
       const codeblocks = content.match(/(<br\/>)?(~~~|```)\w*<br\/>.+?<br\/>\2\1?/g)
       if (codeblocks) {
         codeblocks.forEach((pre) => {
-          content = content.replace(pre, pre.replaceAll('<br/>', '\n'))
+          content = content.replace(pre,
+            pre.replaceAll('<br/>', '\n')
+               .replaceAll('&amp;', '&')
+               .replaceAll('&lt;', '<')
+               .replaceAll('&gt;', '>')
+               .replaceAll('&quot', '"')
+               .replaceAll('&#39;', "'")
+          )
         })
       }