fix(electron): validate external login URL scheme and callback port (#1621)

This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-10-14 08:12:42 +08:00
1 parent d791e52d82
commit 8e5a50623c
3 files changed
+68

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
/**
* The login URL a server hands the desktop app goes to shell.openExternal,
* so only web pages pass: any other scheme (file:, smb:, ms-msdt:, ...)
* would launch whatever OS handler is registered for it.
*/
function isExternalLoginUrl(value) {
try {
const { protocol } = new URL(value);
return protocol === "https:" || protocol === "http:";
} catch {
return false;
}
}
/** A non-privileged port for the loopback callback listener. */
function isCallbackPort(value) {
return Number.isInteger(value) && value >= 1024 && value <= 65535;
}
module.exports = { isExternalLoginUrl, isCallbackPort };