cicy-desktop 2.1.362 → 2.1.363
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/main.js +13 -1
- package/src/utils/window-utils.js +14 -0
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -35,8 +35,20 @@ electronApp.on("web-contents-created", (_e, wc) => {
|
|
|
35
35
|
// an external popup there is an RCE/creds-leak surface. External links go to the
|
|
36
36
|
// system browser instead; trusted/local/about:blank popups are still allowed.
|
|
37
37
|
try {
|
|
38
|
-
const { windowOpenDecision } = require("./utils/window-utils");
|
|
38
|
+
const { windowOpenDecision, isWebUrl } = require("./utils/window-utils");
|
|
39
39
|
wc.setWindowOpenHandler(({ url }) => windowOpenDecision(url, { wc }));
|
|
40
|
+
// 同一件事的另一条入口:直接导航(点链接 / location=)到未知协议。
|
|
41
|
+
// 开窗那条被拦了,这条不拦照样会把 bitbrowser:// 这类交给系统去弹框。
|
|
42
|
+
wc.on("will-navigate", (e, url) => {
|
|
43
|
+
if (isWebUrl(url)) return;
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
let from = "";
|
|
46
|
+
try { from = wc.getURL(); } catch (_) {}
|
|
47
|
+
try {
|
|
48
|
+
require("electron-log").warn(
|
|
49
|
+
`[Navigate] 外部协议已拦截: ${String(url).slice(0, 120)} 来自: ${String(from).slice(0, 120)}`);
|
|
50
|
+
} catch (_) {}
|
|
51
|
+
});
|
|
40
52
|
} catch (_) {}
|
|
41
53
|
// Ctrl/Cmd+C inside a <webview> guest: on Windows the application menu's
|
|
42
54
|
// role:"copy" accelerator doesn't reach the focused guest, so a selection
|
|
@@ -57,8 +57,21 @@ function accountIdxOfWebContents(wc) {
|
|
|
57
57
|
// sandbox profile 1; an opener already in a sandbox profile N opens the link in
|
|
58
58
|
// its OWN profile N. This mirrors the tab-browser policy (profile 0 link →
|
|
59
59
|
// openTab(1); else same profile) — no dialog, no leak into profile 0.
|
|
60
|
+
// 只有这些协议才允许在应用里导航/开窗。其余(bitbrowser:// tg:// whatsapp:// …)
|
|
61
|
+
// 交给 Chromium 就等于交给系统:Windows 弹「获取打开此链接的应用」那个模态框,
|
|
62
|
+
// 机器上没装对应软件也关不掉,自动化直接卡住(实测 2026-09-21,群消息里的
|
|
63
|
+
// bitbrowser:// 推广链接)。这里直接拒掉,并把来源打进日志,便于回溯是谁发起的。
|
|
64
|
+
const WEB_SCHEME = /^(https?|about|blob|data|file|cicyui|devtools|chrome-extension):/i;
|
|
65
|
+
function isWebUrl(u) { return WEB_SCHEME.test(String(u || "")); }
|
|
66
|
+
|
|
60
67
|
function windowOpenDecision(url, { wc } = {}) {
|
|
61
68
|
log.info(`[WindowOpen] Intercepted: ${url}`);
|
|
69
|
+
if (url && !isWebUrl(url)) {
|
|
70
|
+
let from = "";
|
|
71
|
+
try { from = wc ? wc.getURL() : ""; } catch (e) {}
|
|
72
|
+
log.warn(`[WindowOpen] 外部协议已拦截: ${String(url).slice(0, 120)} 来自: ${String(from).slice(0, 120)}`);
|
|
73
|
+
return { action: "deny" };
|
|
74
|
+
}
|
|
62
75
|
if (!url || url === "about:blank" || isTrustedUrl(url)) {
|
|
63
76
|
return {
|
|
64
77
|
action: "allow",
|
|
@@ -567,6 +580,7 @@ if (app) {
|
|
|
567
580
|
}
|
|
568
581
|
|
|
569
582
|
module.exports = {
|
|
583
|
+
isWebUrl,
|
|
570
584
|
createWindow,
|
|
571
585
|
setupWindowHandlers,
|
|
572
586
|
windowOpenDecision,
|