From 4e9d15280d9609fdfb831b7696ca598c9d583442 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 7 Jul 2025 21:55:52 +0200 Subject: [PATCH] fix(frontend): fix dompurify.sanitize import The update to dompurify 3.2.4 broke the import of dompurify.sanitize, which now fails with a TypeScript error (likely related to the introduction of type definitions in 3.2.0). Using the DOMPurify default export fixes the issue. Signed-off-by: Matthias Schiffer --- .../src/components/common/html-to-react/html-to-react.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/common/html-to-react/html-to-react.tsx b/frontend/src/components/common/html-to-react/html-to-react.tsx index e73486793..e616b9dec 100644 --- a/frontend/src/components/common/html-to-react/html-to-react.tsx +++ b/frontend/src/components/common/html-to-react/html-to-react.tsx @@ -6,8 +6,7 @@ import { measurePerformance } from '../../../utils/measure-performance' import type { ParserOptions } from '@hedgedoc/html-to-react' import { convertHtmlToReact } from '@hedgedoc/html-to-react' -import type DOMPurify from 'dompurify' -import { sanitize } from 'dompurify' +import DOMPurify from 'dompurify' import React, { Fragment, useMemo } from 'react' export interface HtmlToReactProps { @@ -28,7 +27,7 @@ const REGEX_URI_SCHEME_NO_SCRIPTS = /^(?!.*script:).+:?/i export const HtmlToReact: React.FC = ({ htmlCode, domPurifyConfig, parserOptions }) => { const elements = useMemo(() => { const sanitizedHtmlCode = measurePerformance('html-to-react: sanitize', () => { - return sanitize(htmlCode, { + return DOMPurify.sanitize(htmlCode, { ...domPurifyConfig, RETURN_DOM_FRAGMENT: false, RETURN_DOM: false,