* Sanitizes HTML content to prevent XSS attacks. * * @param html - Raw HTML string from markdown rendering * @returns Sanitized HTML safe for dangerouslySetInnerHTML
(html: string)
| 227 | * @returns Sanitized HTML safe for dangerouslySetInnerHTML |
| 228 | */ |
| 229 | function sanitizeHTML(html: string): string { |
| 230 | // Use .toString() to ensure we return a string even if Trusted Types are enabled |
| 231 | return DOMPurify.sanitize(html, DOMPURIFY_CONFIG).toString(); |
| 232 | } |
| 233 | |
| 234 | // Initialize markdown-it with plugins (similar to n8n sticky notes) |
| 235 | const md = new MarkdownIt({ |