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:
@@ -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: {} });
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user