Skip to content

Build your personal knowledge base with Trilium Notes

chore(electron): prevent open note custom if file doesn't exist

Elian Doranb005cdfc12f4
diff --git a/apps/server/src/services/window.ts b/apps/server/src/services/window.ts
index 1a6ed36ac9..f137ace95d 100644
--- a/apps/server/src/services/window.ts
+++ b/apps/server/src/services/window.ts
@@ -1,5 +1,6 @@
import { execFile } from "child_process";
import { type App, type BrowserWindow, type BrowserWindowConstructorOptions, default as electron, type Session, type WebContents } from "electron";
+import fs from "fs";
import path from "path";
import url from "url";
@@ -247,6 +248,10 @@ electron.ipcMain.on("open-custom", (_event, filePath: string) => {
throw new Error(`open-custom: refusing path outside tmpdir: ${resolved}`);
}
+ if (!fs.existsSync(resolved)) {
+ throw new Error(`open-custom: file does not exist: ${resolved}`);
+ }
+
const platform = process.platform;
if (platform === "linux") {