fix: validate terminal link URLs before opening in external browser

This commit is contained in:
ZacharyZcR
2026-05-13 16:30:41 +08:00
parent ec87f8a4d1
commit dcc75c980b
2 changed files with 14 additions and 2 deletions
+8 -1
View File
@@ -953,7 +953,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" };
});
}