Import source: app/backend/src/lib/sanitize

Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
This commit is contained in:
arsam
2026-09-18 23:19:38 +03:30
parent 218259682c
commit 2de6f702a2
+18
View File
@@ -0,0 +1,18 @@
import sanitizeHtml from 'sanitize-html';
const COMMENT_OPTIONS: sanitizeHtml.IOptions = {
allowedTags: ['b', 'i', 'em', 'strong', 'a', 'code', 'br'],
allowedAttributes: {
a: ['href', 'title'],
},
allowedSchemes: ['https'],
disallowedTagsMode: 'discard',
};
export function sanitizeComment(input: string): string {
return sanitizeHtml(input, COMMENT_OPTIONS);
}
export function stripHtml(input: string): string {
return sanitizeHtml(input, { allowedTags: [], allowedAttributes: {} });
}