mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
fix: 🎨 Switch from happy-dom to jsdom for HTML sanitization
This commit is contained in:
parent
68badc5caa
commit
7a90abeaec
3 changed files with 111 additions and 115 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue