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
2026-05-18 04:35:11 +08:00
committed by GitHub
2 changed files with 14 additions and 2 deletions
+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" };
});
}