Co-authored-by: Yash Singh <[email protected]> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
30 lines
1019 B
TypeScript
30 lines
1019 B
TypeScript
import { expect, it } from "vite-plus/test";
|
|
import { unified } from "unified";
|
|
import remarkParse from "remark-parse";
|
|
import remarkRehype from "remark-rehype";
|
|
import { CHAT_MARKDOWN_REHYPE_PLUGINS, CHAT_MARKDOWN_REMARK_PLUGINS } from "./markdownPipeline.ts";
|
|
|
|
it("preserves in-app thread links through the shared Markdown sanitizer", () => {
|
|
const processor = unified()
|
|
.use(remarkParse)
|
|
.use(CHAT_MARKDOWN_REMARK_PLUGINS)
|
|
.use(remarkRehype, { allowDangerousHtml: true })
|
|
.use(CHAT_MARKDOWN_REHYPE_PLUGINS);
|
|
const tree = processor.runSync(
|
|
processor.parse(
|
|
'[Open thread](t3-thread://v1/environment/thread)\n\n<a href="javascript:alert(1)">Unsafe</a>',
|
|
),
|
|
);
|
|
expect(tree.children[0]).toMatchObject({
|
|
tagName: "p",
|
|
children: [
|
|
{
|
|
tagName: "a",
|
|
properties: { href: "t3-thread://v1/environment/thread" },
|
|
children: [{ type: "text", value: "Open thread" }],
|
|
},
|
|
],
|
|
});
|
|
expect(JSON.stringify(tree)).not.toContain("javascript:");
|
|
});
|