Merge pull request #769 from ZacharyZcR/fix/electron-url-handler

fix: validate terminal link URLs before opening in external browser
This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-05-18 04:35:11 +08:00
commit d27d8ad149
2 files changed
+14 -2

No files matched your search

+8 -1
View File
@@ -955,7 +955,14 @@ function createWindow() {
});
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
shell.openExternal(url);
try {
const parsed = new URL(url);
if (parsed.protocol === "http:" || parsed.protocol === "https:") {
shell.openExternal(url);
}
} catch {
// invalid URL, ignore
}
return { action: "deny" };
});
}