refactor(ui): extract shared sanitized-Markdown renderer (T7.1)

Notes and LLM-generated summaries both render untrusted Markdown via
{@html} into a webview with an IPC bridge to the Rust backend, so the
DOMPurify sanitization step is a real security boundary, not cosmetic —
worth one shared implementation instead of a second inline copy that
could drift out of sync.
This commit is contained in:
iamdoubz
2026-07-02 07:44:41 -05:00
parent 5f8ba8253e
commit 4609d93faf
+11
View File
@@ -0,0 +1,11 @@
// Shared Markdown rendering for any Markdown that isn't guaranteed to be our
// own trusted output (notes, LLM-generated summaries) — this webview has an
// IPC bridge to the Rust backend, so unsanitized `{@html}` here would be a
// real local-privilege risk, not just a cosmetic one. Kept in one place so a
// future sanitization fix can't miss a second copy.
import { marked } from "marked";
import DOMPurify from "dompurify";
export function renderMarkdown(markdown: string): string {
return DOMPurify.sanitize(marked.parse(markdown || "") as string);
}