mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix: 🎨 Switch from happy-dom to jsdom for HTML sanitization
This commit is contained in:
parent
68badc5caa
commit
7a90abeaec
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue