Skip to content

Commit 89e8e1e

Browse files
authored
fix(pack): remove owned Windows protocol on uninstall (#6694)
1 parent 85c5d9b commit 89e8e1e

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

tools/pack/src/win/custom-installer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,13 @@ after_desktop_shortcut:
10121012
DeleteRegKey HKCU "${registryKey}"
10131013
DeleteRegKey HKCU "${appPathsKey}"
10141014
ReadRegStr $0 HKCU "${inviteProtocolKey}\\shell\\open\\command" ""
1015-
StrCmp $0 '$\"$INSTDIR\\${exeName}$\" $\"%1$\"' 0 preserve_invite_protocol
1015+
; Electron refreshes the protocol command when the app starts and may change
1016+
; its trailing arguments. Compare only the exact quoted executable prefix so
1017+
; this install can remove its registration without touching another owner.
1018+
StrCpy $1 '$\"$INSTDIR\\${exeName}$\"'
1019+
StrLen $2 $1
1020+
StrCpy $3 $0 $2
1021+
StrCmp $3 $1 0 preserve_invite_protocol
10161022
DeleteRegKey HKCU "${inviteProtocolKey}"
10171023
preserve_invite_protocol:
10181024
Push "event=registry_after_delete key=${registryKey} appPathsKey=${appPathsKey}"

tools/pack/tests/win-identity.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe("resolveWinInstallIdentity", () => {
8383
expect(source).not.toContain('"DisplayName" "${productName} \\${APP_VERSION}"');
8484
});
8585

86-
it("registers the invite protocol and removes it on uninstall only while this install owns it", async () => {
86+
it("removes an Electron-refreshed invite protocol while this install still owns it", async () => {
8787
const source = await readFile(new URL("../src/win/custom-installer.ts", import.meta.url), "utf8");
8888
expect(source).toContain('const inviteProtocolKey = "Software\\\\Classes\\\\opendesign"');
8989
expect(source).toContain('WriteRegStr HKCU "${inviteProtocolKey}" "URL Protocol" ""');
@@ -94,12 +94,16 @@ describe("resolveWinInstallIdentity", () => {
9494
expect(source).toContain(
9595
'ReadRegStr $0 HKCU "${inviteProtocolKey}\\\\shell\\\\open\\\\command" ""',
9696
);
97-
expect(source).toContain(
97+
expect(source).toContain("StrCpy $1 '$\\\"$INSTDIR\\\\${exeName}$\\\"'");
98+
expect(source).toContain("StrLen $2 $1");
99+
expect(source).toContain("StrCpy $3 $0 $2");
100+
expect(source).toContain("StrCmp $3 $1 0 preserve_invite_protocol");
101+
expect(source).not.toContain(
98102
"StrCmp $0 '$\\\"$INSTDIR\\\\${exeName}$\\\" $\\\"%1$\\\"' 0 preserve_invite_protocol",
99103
);
100104
expect(source).toContain('DeleteRegKey HKCU "${inviteProtocolKey}"');
101105
expect(source).toContain("preserve_invite_protocol:");
102-
expect(source.indexOf("StrCmp $0")).toBeLessThan(
106+
expect(source.indexOf("StrCmp $3 $1")).toBeLessThan(
103107
source.indexOf('DeleteRegKey HKCU "${inviteProtocolKey}"'),
104108
);
105109
expect(source.indexOf('DeleteRegKey HKCU "${inviteProtocolKey}"')).toBeLessThan(

0 commit comments

Comments
 (0)