feat: add rehype-sanitize for enhanced Markdown security

- Added rehype-sanitize as a dependency to sanitize Markdown content.
- Updated the Markdown component to include rehype-sanitize in the rehypePlugins for improved security against XSS attacks.
This commit is contained in:
Kacper
2025-12-22 20:22:40 +01:00
parent a0fd19fe17
commit 0b8a79bc25
3 changed files with 34 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import ReactMarkdown from 'react-markdown';
import rehypeRaw from 'rehype-raw';
import rehypeSanitize from 'rehype-sanitize';
import { cn } from '@/lib/utils';
interface MarkdownProps {
@@ -44,7 +45,7 @@ export function Markdown({ children, className }: MarkdownProps) {
className
)}
>
<ReactMarkdown rehypePlugins={[rehypeRaw]}>{children}</ReactMarkdown>
<ReactMarkdown rehypePlugins={[rehypeRaw, rehypeSanitize]}>{children}</ReactMarkdown>
</div>
);
}