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(electron): open note custom not triggering on Windows
Elian Doran551db33d9ea5
diff --git a/apps/server/src/services/window.ts b/apps/server/src/services/window.tsindex 971074cca4..1a6ed36ac9 100644--- a/apps/server/src/services/window.ts+++ b/apps/server/src/services/window.ts@@ -274,7 +274,13 @@ electron.ipcMain.on("open-custom", (_event, filePath: string) => {tryTerminal(0);} else if (platform === "win32") {const winPath = resolved.replace(/\//g, "\\");- execFile("rundll32.exe", ["shell32.dll,OpenAs_RunDLL", winPath], (err) => {+ // OpenAs_RunDLL doesn't strip surrounding quotes from its arg, so we+ // must NOT let Node quote the path on our behalf. windowsVerbatimArguments+ // is safe here: CreateProcess passes the command line to rundll32 without+ // any shell interpretation (so `&` is inert), and the path is validated+ // above to live inside dataDirs.TMP_DIR with a sanitize-filename'd basename+ // (so it cannot contain quotes or other rundll32-confusing characters).+ execFile("rundll32.exe", ["shell32.dll,OpenAs_RunDLL", winPath], { windowsVerbatimArguments: true }, (err) => {if (err) {log.error(`open-custom: rundll32 failed: ${err.message}`);electron.shell.openPath(resolved);