fix: 🎨 Switch from happy-dom to jsdom for HTML sanitization

This commit is contained in:
Jesse Wierzbinski 2024-05-02 13:53:10 -10:00
parent 68badc5caa
commit 7a90abeaec
No known key found for this signature in database
3 changed files with 111 additions and 115 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -77,14 +77,13 @@
"cli-parser": "workspace:*",
"cli-table": "^0.3.11",
"config-manager": "workspace:*",
"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",
"iso-639-1": "^3.1.0",
"isomorphic-dompurify": "^2.9.0",
"jose": "^5.2.4",
"linkify-html": "^4.1.3",
"linkify-string": "^4.1.3",

View file

@ -1,14 +1,11 @@
import { config } from "config-manager";
import type DOMPurify from "dompurify";
import createDomPurify from "dompurify";
import { Window } from "happy-dom";
import DOMPurify from "isomorphic-dompurify";
const window = new Window();
// @ts-expect-error Mismatch between types, but they're okay i swear
const purifier = createDomPurify(window);
export const sanitizeHtml = async (html: string, extraConfig?: DOMPurify.Config) => {
const sanitizedHtml = purifier.sanitize(html, {
export const sanitizeHtml = async (
html: string,
extraConfig?: DOMPurify.Config,
) => {
const sanitizedHtml = DOMPurify.sanitize(html, {
ALLOWED_TAGS: [
"a",
"p",