add DOMPurify

This commit is contained in:
_Bastler
2022-02-27 14:37:26 +01:00
parent 9e86e95135
commit 86dc0d4aa8
3 changed files with 9 additions and 3 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
// import sanitizeHtml from 'sanitize-html';
import DOMPurify from 'dompurify';
export class HtmlUtils {
public static getElementByIdOrFail<T extends HTMLElement>(id: string): T {
@@ -40,8 +40,8 @@ export class HtmlUtils {
public static sanitize(html: string | number | boolean | undefined): string {
if (typeof html === "string") {
return html;
/* TODO: fix sanitizer, sanitizeHtml seems not to work with vite
return DOMPurify.sanitize(html);
/* TODO: fix sanitizer, apply sanitizeHtml rules to DOMPurify
return sanitizeHtml(html, {
allowedAttributes: {
span: ["style"],