The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 09:30 UTC
fix(desktop): data: popups no longer replace the preview tab (#24866)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 31, 2026 at 03:39 UTC
c94ff9b6e55cf3f28c4e2eb022b49035feba6db6
2 files changed
+44
-13
apps/desktop/src/preview/Manager.test.ts
+26
-3
@@ -86,6 +86,12 @@ describe("previewWindowOpenAction", () => {
86
).toBe("popup");
87
});
88
89
+ it("opens HTTP links in preview tabs", () => {
90
+ for (const disposition of ["foreground-tab", "background-tab"] as const) {
91
+ expect(PreviewManager.previewWindowOpenAction(details({ disposition }))).toBe("new-tab");
92
+ }
93
+ });
94
+
95
it("keeps a form POST with a body on the in-place path", () => {
96
const postBody = { data: [], contentType: "application/x-www-form-urlencoded" };
97
expect(
@@ -98,15 +104,32 @@ describe("previewWindowOpenAction", () => {
104
105
it("does not hand a window to schemes that cannot be hardened", () => {
106
for (const url of [
101
- "javascript:alert(1)",
102
- "file:///etc/passwd",
107
"vscode://vscode-remote/ssh-remote+box/tmp",
104
- "not a url",
108
+ "blob:https://example.com/0b6c6a5e-55d4-4b4c-9d47-8f1b0c1d2e3f",
109
]) {
110
expect(PreviewManager.previewWindowOpenAction(details({ url }))).toBe("navigate");
111
}
112
});
113
114
+ it("denies local and inline schemes that no page could open in place itself", () => {
115
+ for (const url of [
116
+ "data:text/html,<h1>hi</h1>",
117
+ "DaTa:text/html,<h1>hi</h1>",
118
+ "file:///etc/passwd",
119
+ "javascript:alert(1)",
120
+ "view-source:https://example.com",
121
+ "chrome://gpu",
122
+ "about:srcdoc",
123
+ "devtools://devtools/bundled/inspector.html",
124
+ "filesystem:https://example.com/temporary/page.html",
125
+ "not a url",
126
+ ]) {
127
+ for (const disposition of ["new-window", "foreground-tab", "background-tab"] as const) {
128
+ expect(PreviewManager.previewWindowOpenAction(details({ url, disposition }))).toBe("deny");
129
+ }
130
+ }
131
+ });
132
+
133
it("denies a blank window instead of blanking the opener", () => {
134
for (const url of ["about:blank", ""]) {
135
for (const disposition of ["new-window", "foreground-tab"] as const) {
apps/desktop/src/preview/Manager.ts
+18
-10
@@ -423,13 +423,17 @@ type OpenLinkListener = (event: DesktopPreviewOpenLinkEvent) => Effect.Effect<vo
423
// about:blank inherits relaxed guest preferences; external editor schemes must reach the OS handler.
424
const POPUP_PROTOCOLS = new Set(["http:", "https:"]);
425
426
-const isPopupUrl = (rawUrl: string): boolean => {
427
- try {
428
- return POPUP_PROTOCOLS.has(new URL(rawUrl).protocol);
429
- } catch {
430
- return false;
431
- }
432
-};
426
+// Main-process loadURL bypasses Chromium's renderer-side restrictions on local and inline URLs.
427
+const IN_PLACE_DENIED_PROTOCOLS = new Set([
428
+ "about:",
429
+ "chrome:",
430
+ "data:",
431
+ "devtools:",
432
+ "file:",
433
+ "filesystem:",
434
+ "javascript:",
435
+ "view-source:",
436
+]);
437
438
/** Popups bypass will-attach-webview hardening and would inherit the picker's contextIsolation:false. */
439
const POPUP_WINDOW_OPTIONS = {
@@ -440,15 +444,19 @@ const POPUP_WINDOW_OPTIONS = {
444
},
445
} satisfies Electron.BrowserWindowConstructorOptions;
446
443
-/** OAuth needs a surviving popup opener; unhardenable schemes and form POSTs must stay in place. */
447
+/**
448
+ * OAuth needs a surviving popup opener. `blob:`, app links (behind the session's `openExternal`
449
+ * prompt) and form POSTs stay in place.
450
+ */
451
export const previewWindowOpenAction = (details: {
452
readonly url: string;
453
readonly disposition: Electron.HandlerDetails["disposition"];
454
readonly postBody?: Electron.PostBody;
455
}): "popup" | "new-tab" | "navigate" | "deny" => {
456
+ const protocol = URL.parse(details.url)?.protocol;
457
// MSAL redirects on a denied blank popup; navigating the tab would destroy that fallback.
450
- if (details.url === "" || details.url === "about:blank") return "deny";
451
- if (!isPopupUrl(details.url)) return "navigate";
458
+ if (protocol === undefined || IN_PLACE_DENIED_PROTOCOLS.has(protocol)) return "deny";
459
+ if (!POPUP_PROTOCOLS.has(protocol)) return "navigate";
460
if (details.disposition === "new-window") return "popup";
461
return !details.postBody &&
462
(details.disposition === "foreground-tab" || details.disposition === "background-tab")