mirror of
https://github.com/versia-pub/server.git
synced 2026-01-26 20:26:01 +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-parser": "workspace:*",
|
||||||
"cli-table": "^0.3.11",
|
"cli-table": "^0.3.11",
|
||||||
"config-manager": "workspace:*",
|
"config-manager": "workspace:*",
|
||||||
"dompurify": "^3.1.2",
|
|
||||||
"drizzle-orm": "^0.30.7",
|
"drizzle-orm": "^0.30.7",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
"happy-dom": "14.5.0",
|
|
||||||
"html-to-text": "^9.0.5",
|
"html-to-text": "^9.0.5",
|
||||||
"ioredis": "^5.3.2",
|
"ioredis": "^5.3.2",
|
||||||
"ip-matching": "^2.1.2",
|
"ip-matching": "^2.1.2",
|
||||||
"iso-639-1": "^3.1.0",
|
"iso-639-1": "^3.1.0",
|
||||||
|
"isomorphic-dompurify": "^2.9.0",
|
||||||
"jose": "^5.2.4",
|
"jose": "^5.2.4",
|
||||||
"linkify-html": "^4.1.3",
|
"linkify-html": "^4.1.3",
|
||||||
"linkify-string": "^4.1.3",
|
"linkify-string": "^4.1.3",
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
import { config } from "config-manager";
|
import { config } from "config-manager";
|
||||||
import type DOMPurify from "dompurify";
|
import DOMPurify from "isomorphic-dompurify";
|
||||||
import createDomPurify from "dompurify";
|
|
||||||
import { Window } from "happy-dom";
|
|
||||||
|
|
||||||
const window = new Window();
|
export const sanitizeHtml = async (
|
||||||
// @ts-expect-error Mismatch between types, but they're okay i swear
|
html: string,
|
||||||
const purifier = createDomPurify(window);
|
extraConfig?: DOMPurify.Config,
|
||||||
|
) => {
|
||||||
export const sanitizeHtml = async (html: string, extraConfig?: DOMPurify.Config) => {
|
const sanitizedHtml = DOMPurify.sanitize(html, {
|
||||||
const sanitizedHtml = purifier.sanitize(html, {
|
|
||||||
ALLOWED_TAGS: [
|
ALLOWED_TAGS: [
|
||||||
"a",
|
"a",
|
||||||
"p",
|
"p",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue