Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: code blocks of unknown languages cause HTML injection (#3711)

andrigameritad264f459797b
diff --git a/web/src/components/MemoContent/CodeBlock.tsx b/web/src/components/MemoContent/CodeBlock.tsx
index e96838eb8..d9177a5d2 100644
--- a/web/src/components/MemoContent/CodeBlock.tsx
+++ b/web/src/components/MemoContent/CodeBlock.tsx
@@ -42,7 +42,10 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => {
// Skip error and use default highlighted code.
}
- return content;
+ // escape any HTML entities when rendering original content
+ return Object.assign(document.createElement("span"), {
+ textContent: content,
+ }).innerHTML;
}, [formatedLanguage, content]);
const handleCopyButtonClick = useCallback(() => {