[FA-misc] Should be good
This commit is contained in:
12
fictionarchive-web-astro/src/lib/utils/sanitize.ts
Normal file
12
fictionarchive-web-astro/src/lib/utils/sanitize.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import DOMPurify from 'dompurify';
|
||||
|
||||
/**
|
||||
* Sanitizes HTML content, allowing only safe inline formatting elements.
|
||||
* Removes scripts, event handlers, iframes, and other risky elements.
|
||||
*/
|
||||
export function sanitizeHtml(html: string): string {
|
||||
return DOMPurify.sanitize(html, {
|
||||
ALLOWED_TAGS: ['b', 'i', 'em', 'strong', 'br', 'p', 'span'],
|
||||
ALLOWED_ATTR: []
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user