Skip to content

Build your personal knowledge base with Trilium Notes

Merge branch 'main' into feat/fun-take1

perfectra1n732d1280c05b
diff --cc apps/client/src/widgets/react/RawHtml.tsx
index bf2e2012b6,502fc56f5d..25a37ea93f
--- a/apps/client/src/widgets/react/RawHtml.tsx
+++ b/apps/client/src/widgets/react/RawHtml.tsx
@@@ -1,7 -1,6 +1,8 @@@
+ 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"> {
@@@ -38,6 -37,22 +39,22 @@@ export function getHtml(html: string |
}
return {
- __html: html as string
+ __html: sanitizeNoteContentHtml(html as string)
};
}
+
+ /**
+ * Renders HTML content sanitized via DOMPurify to prevent XSS.
+ * Use this instead of {@link RawHtml} when the HTML originates from
+ * untrusted sources (e.g. LLM responses, user-generated markdown).
+ */
+ export function SanitizedHtml({ className, html, style }: { className?: string; html: string; style?: CSSProperties }) {
+ return (
+ <div
+ className={className}
+ style={style}
+ // eslint-disable-next-line react/no-danger
+ dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(html) }}
+ />
+ );
+ }
diff --cc apps/server/src/routes/api/options.ts
index d18d9d1218,ce5d7b9dc6..c9940b9875
--- a/apps/server/src/routes/api/options.ts
+++ b/apps/server/src/routes/api/options.ts
@@@ -104,16 -104,15 +104,22 @@@ const ALLOWED_OPTIONS = new Set<OptionN
"experimentalFeatures",
"newLayout",
"mfaEnabled",
- "mfaMethod"
+ "mfaMethod",
+ // LLM options
+ "llmProviders",
+ "mcpEnabled",
+ // OCR options
+ "ocrAutoProcessImages",
+ "ocrMinConfidence"
]);
+// Options that contain secrets (API keys, tokens, etc.).
+// These can be written by the client but are never sent back in GET responses.
+const WRITE_ONLY_OPTIONS = new Set<OptionNames>([
+ "openaiApiKey",
+ "anthropicApiKey"
+]);
+
function getOptions() {
const optionMap = optionService.getOptionMap();
const resultMap: Record<string, string> = {};
diff --cc pnpm-lock.yaml
index a539236649,abd7ec647e..f79c5d220d
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@@ -485,11 -502,11 +508,11 @@@ importers
specifier: 1.0.2
version: 1.0.2
copy-webpack-plugin:
- specifier: 14.0.0
+ specifier: 13.0.1
electron:
- specifier: 41.1.0
- version: 41.1.0
+ specifier: 40.4.1
+ version: 40.4.1
prebuild-install:
specifier: 7.1.3
version: 7.1.3
@@@ -8274,12 -7649,6 +7665,12 @@@ packages
resolution: {integrity: sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==}
+ resolution: {integrity: sha512-J+YV3WfhY6W/Xf9h+J1znYuqTye2xkBUIGyTPWuBAT27qajBa5mR4f8WBmfDY3YjRftT2kqZZiLi1qf0H+UOFw==}
+ engines: {node: '>= 18.12.0'}
+ peerDependencies:
- webpack: ^5.1.0
++ webpack: '>=5.104.1'
+
resolution: {integrity: sha512-3JLW90aBGeaTLpM7mYQKpnVdgsUZRExY55giiZgLuX/xTQRUs1dOCwbBnWnvY6Q6rfZoXMNwzOQJCSZPppfqXA==}
engines: {node: '>= 20.9.0'}
@@@ -9064,13 -8334,8 +8356,13 @@@
resolution: {integrity: sha512-bO3y10YikuUwUuDUQRM4KfwNkKhnpVO7IPdbsrejwN9/AABJzzTQ4GeHwyzNSrVO+tEH3/Np255a3sVZpZDjvg==}
engines: {node: '>=8.0.0'}
+ resolution: {integrity: sha512-N1ZXybQZL8kYemO8vAeh9nrk4mSvqlAO8xs0QCHkXIvRnuB/7VGwEehjvQbsU5/f4bmTKpG+2GQERe/zmKpudQ==}
+ engines: {node: '>= 12.20.55'}
+ hasBin: true
+
- resolution: {integrity: sha512-IDjx8liW1q+r7+MOip5W1Eo1eMwJzVObmYrd9yz2dPCkS7XlgLq3qPVMR80TpiROFp73iY30kTzMdpA6fEVs3A==}
+ resolution: {integrity: sha512-0XRFyxRqetmqtkkBvV++wGbHYJ7bD++f6EgJW8y9kX4pPRagwlmKDtzqXZhKiu0DIQppm3sXxzHWK9GYP91OKQ==}
engines: {node: '>= 12.20.55'}
hasBin: true
@@@ -18397,15 -16315,9 +16351,15 @@@ snapshots
glob: 7.2.3
minimatch: 3.1.5
+ '@electron/[email protected]':
+ dependencies:
+ chalk: 4.1.2
+ fs-extra: 9.1.0
+ minimist: 1.2.8
+
'@electron/[email protected]':
dependencies:
- debug: 4.4.3([email protected])
+ debug: 4.4.3
env-paths: 2.2.1
fs-extra: 8.1.0
got: 11.8.6
@@@ -18528,13 -16440,9 +16482,13 @@@
transitivePeerDependencies:
- supports-color
+ dependencies:
+ electron: 40.4.1
+
dependencies:
- electron: 41.0.3
+ electron: 41.1.0
'@electron/[email protected]':
dependencies:
@@@ -25599,16 -23050,7 +23096,16 @@@
is-what: 3.14.1
optional: true
+ dependencies:
+ glob-parent: 6.0.2
+ normalize-path: 3.0.0
- schema-utils: 4.3.2
- serialize-javascript: 6.0.2
++ schema-utils: 4.3.3
++ serialize-javascript: 7.0.5
+ tinyglobby: 0.2.15
- webpack: 5.101.3([email protected])
++ webpack: 5.105.4([email protected])
+
dependencies:
glob-parent: 6.0.2
normalize-path: 3.0.0
@@@ -26512,15 -23839,7 +23894,15 @@@
- supports-color
optional: true
+ dependencies:
+ '@electron/get': 2.0.3
+ '@types/node': 24.12.0
+ extract-zip: 2.0.1
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
'@electron/get': 2.0.3
'@types/node': 24.12.0