Skip to content

Commit e080968

Browse files
committed
Fix plugin order: sanitize after parsing raw HTML
Move rehype-harden after rehypeRaw to ensure all HTML is sanitized. Previously, harden ran before rehypeRaw, allowing unsanitized HTML to be injected after the security check.
1 parent dda5e54 commit e080968

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/Messages/MarkdownCore.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ const REMARK_PLUGINS: Pluggable[] = [
2323
];
2424

2525
const REHYPE_PLUGINS: Pluggable[] = [
26+
rehypeRaw, // Parse HTML elements first
2627
[
27-
harden,
28+
harden, // Sanitize after parsing raw HTML to prevent XSS
2829
{
2930
allowedImagePrefixes: ["*"],
3031
allowedLinkPrefixes: ["*"],
3132
defaultOrigin: undefined,
3233
allowDataImages: true,
3334
},
3435
],
35-
rehypeRaw, // Parse HTML elements
3636
[rehypeKatex, { errorColor: "var(--color-muted-foreground)" }], // Render math
3737
];
3838

0 commit comments

Comments
 (0)