fix: isomorphic dompurify #8301

This commit is contained in:
M. Palanikannan 2025-12-10 19:51:11 +05:30 committed by GitHub
parent 67dfe91890
commit 76ebf395e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 393 additions and 14 deletions

View file

@ -32,7 +32,6 @@
"@hocuspocus/transformer": "2.15.2",
"@plane/decorators": "workspace:*",
"@plane/editor": "workspace:*",
"@plane/utils": "workspace:*",
"@plane/logger": "workspace:*",
"@plane/types": "workspace:*",
"@sentry/node": "catalog:",
@ -46,6 +45,7 @@
"express-ws": "^5.0.2",
"helmet": "^7.1.0",
"ioredis": "5.7.0",
"isomorphic-dompurify": "^1.8.0",
"uuid": "catalog:",
"ws": "^8.18.3",
"y-prosemirror": "^1.3.7",

View file

@ -1,4 +1,14 @@
import { sanitizeHTML } from "@plane/utils";
import DOMPurify from "isomorphic-dompurify";
/**
* Sanitizes HTML by removing all HTML tags, leaving only text content
* @param htmlString - The HTML string to sanitize
* @returns The sanitized text with all HTML tags removed
*/
const sanitizeHTML = (htmlString: string): string => {
const sanitizedText = DOMPurify.sanitize(htmlString, { ALLOWED_TAGS: [] }); // sanitize the string to remove all HTML tags
return sanitizedText.trim(); // trim the string to remove leading and trailing whitespaces
};
/**
* Utility function to extract text from HTML content