diff --git a/packages/dashboard/app/components/MailboxMessageContent.tsx b/packages/dashboard/app/components/MailboxMessageContent.tsx index 61b1d865a5..3316727f3a 100644 --- a/packages/dashboard/app/components/MailboxMessageContent.tsx +++ b/packages/dashboard/app/components/MailboxMessageContent.tsx @@ -1,52 +1,19 @@ import { memo } from "react"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; -import rehypeRaw from "rehype-raw"; -import rehypeSanitize, { defaultSchema } from "rehype-sanitize"; -import type { Options as SanitizeSchema } from "rehype-sanitize"; import type { Components } from "react-markdown"; import type { PluggableList } from "unified"; import { linkifyReactChildren } from "../utils/filePathLinkify"; -import { MermaidDiagram } from "./MermaidDiagram"; +import { sharedRehypePlugins, createMermaidCodeComponent } from "./markdownPipeline"; /* -FNXC:Markdown 2026-06-23-03:15: -GitHub PR/issue bodies + comments (and mailbox/chat) embed raw HTML (`
`, -``, ``, ``, tables), HTML comments (``), and ```mermaid -blocks. Previously raw HTML was escaped to literal text and mermaid showed as code. - -Pipeline (ORDER MATTERS): remark-gfm -> rehype-raw -> rehype-sanitize. -- rehype-raw parses embedded HTML into the hast tree so it renders as real elements. - It also DROPS HTML comments by default, so `` never appears in output. -- rehype-sanitize runs AFTER raw to strip XSS: ", + "", + "```mermaid", + "graph TD; A-->B;", + "```", + ].join("\n"); + + const { container } = render( + + + , + ); + + // Raw
/ renders as a real disclosure element. + const details = container.querySelector(".markdown-body details"); + expect(details).not.toBeNull(); + expect(details?.querySelector("summary")?.textContent).toBe("Disclosure title"); + expect(details?.textContent).toContain("Hidden detail body."); + + // HTML comment is dropped, never shown as literal text. + expect(container.textContent).not.toContain("secret comment"); + + //