diff --git a/bun.lockb b/bun.lockb index 5d87acac..f5ac5cc9 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index cb809cfb..0176d42b 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "dompurify": "^3.1.2", "drizzle-orm": "^0.30.7", "extract-zip": "^2.0.1", + "happy-dom": "14.5.0", "html-to-text": "^9.0.5", "ioredis": "^5.3.2", "ip-matching": "^2.1.2", diff --git a/utils/sanitization.ts b/utils/sanitization.ts index 4fb34313..65a65beb 100644 --- a/utils/sanitization.ts +++ b/utils/sanitization.ts @@ -1,12 +1,15 @@ import { config } from "config-manager"; import DOMPurify from "dompurify"; -import { JSDOM } from "jsdom"; +import { Window } from "happy-dom"; + +const window = new Window(); export const sanitizeHtml = async ( html: string, extraConfig?: DOMPurify.Config, ) => { - const sanitizedHtml = DOMPurify(new JSDOM().window).sanitize(html, { + // @ts-expect-error Types clash but it works i swear + const sanitizedHtml = DOMPurify(window).sanitize(html, { ALLOWED_TAGS: [ "a", "p",