Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(client): resolve issue with sanitized HTML in client
perfectra1n554ada65b297
diff --git a/apps/client/src/widgets/dialogs/revisions.tsx b/apps/client/src/widgets/dialogs/revisions.tsxindex 66ce763a3d..1772f60f1a 100644--- a/apps/client/src/widgets/dialogs/revisions.tsx+++ b/apps/client/src/widgets/dialogs/revisions.tsx@@ -14,6 +14,7 @@ import { t } from "../../services/i18n";import { renderMathInElement } from "../../services/math";import open from "../../services/open";import options from "../../services/options";+import { sanitizeNoteContentHtml } from "../../services/sanitize_content.js";import protected_session_holder from "../../services/protected_session_holder";import server from "../../services/server";import toast from "../../services/toast";@@ -291,7 +292,7 @@ function RevisionContentText({ content }: { content: string | Buffer<ArrayBufferrenderMathInElement(contentRef.current, { trust: true });}}, [content]);- return <RawHtmlBlock containerRef={contentRef} className="ck-content" html={content as string} />;+ return <RawHtmlBlock containerRef={contentRef} className="ck-content" html={sanitizeNoteContentHtml(content as string)} />;}function RevisionContentDiff({ noteContent, itemContent, itemType }: {diff --git a/apps/client/src/widgets/react/RawHtml.tsx b/apps/client/src/widgets/react/RawHtml.tsxindex 25a37ea93f..502fc56f5d 100644--- a/apps/client/src/widgets/react/RawHtml.tsx+++ b/apps/client/src/widgets/react/RawHtml.tsx@@ -1,8 +1,6 @@import DOMPurify from "dompurify";import type { CSSProperties, HTMLProps, RefObject } from "preact/compat";-import { sanitizeNoteContentHtml } from "../../services/sanitize_content.js";-type HTMLElementLike = string | HTMLElement | JQuery<HTMLElement>;interface RawHtmlProps extends Pick<HTMLProps<HTMLElement>, "tabindex" | "dir"> {@@ -39,7 +37,7 @@ export function getHtml(html: string | HTMLElement | JQuery<HTMLElement>) {}return {- __html: sanitizeNoteContentHtml(html as string)+ __html: html as string};}diff --git a/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx b/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsxindex 3352f621a0..b6f4267b09 100644--- a/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx+++ b/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx@@ -13,6 +13,7 @@ import { applyInlineMermaid, rewriteMermaidDiagramsInContainer } from "../../../import { getLocaleById } from "../../../services/i18n";import { renderMathInElement } from "../../../services/math";import { formatCodeBlocks } from "../../../services/syntax_highlight";+import { sanitizeNoteContentHtml } from "../../../services/sanitize_content.js";import { useNoteBlob, useNoteLabel, useTriliumEvent, useTriliumOptionBool } from "../../react/hooks";import { RawHtmlBlock } from "../../react/RawHtml";import TouchBar, { TouchBarButton, TouchBarSpacer } from "../../react/TouchBar";@@ -61,7 +62,7 @@ export default function ReadOnlyText({ note, noteContext, ntxId }: TypeWidgetProclassName={clsx("note-detail-readonly-text-content ck-content use-tn-links selectable-text", codeBlockWordWrap && "word-wrap")}tabindex={100}dir={isRtl ? "rtl" : "ltr"}- html={blob?.content}+ html={blob?.content ? sanitizeNoteContentHtml(blob.content as string) : undefined}/><TouchBar>