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: iframe rendering (#3916)

ti7777776f3d5762ca55
diff --git a/web/src/components/MemoContent/CodeBlock.tsx b/web/src/components/MemoContent/CodeBlock.tsx
index 4b733015f..25d056cc0 100644
--- a/web/src/components/MemoContent/CodeBlock.tsx
+++ b/web/src/components/MemoContent/CodeBlock.tsx
@@ -25,7 +25,17 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => {
// Users can set Markdown code blocks as `__html` to render HTML directly.
if (formatedLanguage === SpecialLanguage.HTML) {
const purify = DOMPurify(window);
- return <div className="w-full overflow-auto !my-2" dangerouslySetInnerHTML={{ __html: purify.sanitize(content) }} />;
+ return (
+ <div
+ className="w-full overflow-auto !my-2"
+ dangerouslySetInnerHTML={{
+ __html: purify.sanitize(content, {
+ ALLOWED_TAGS: ["iframe"],
+ ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling"],
+ }),
+ }}
+ />
+ );
} else if (formatedLanguage === SpecialLanguage.MERMAID) {
return <MermaidBlock content={content} />;
}