Skip to content

Commit 6a8a218

Browse files
implementing whitelisted protocols to allow configuring linkifiers in the settings.json
1 parent 13f3818 commit 6a8a218

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

app/common/config-schemata.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const configSchemata = {
3636
useManualProxy: z.boolean(),
3737
useProxy: z.boolean(),
3838
useSystemProxy: z.boolean(),
39+
whitelistedProtocols: z.string().array(),
3940
};
4041

4142
export const enterpriseConfigSchemata = {

app/common/link-util.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ import fs from "node:fs";
33
import os from "node:os";
44
import path from "node:path";
55

6+
import * as ConfigUtil from "./config-util.js";
67
import {html} from "./html.js";
78

9+
/* Fetches the current protocolLaunchers from settings.json */
10+
const whitelistedProtocols = ConfigUtil.getConfigItem("whitelistedProtocols", [
11+
"http:",
12+
"https:",
13+
"mailto:",
14+
"tel:",
15+
"sip:",
16+
]);
17+
818
export async function openBrowser(url: URL): Promise<void> {
9-
if (["http:", "https:", "mailto:"].includes(url.protocol)) {
19+
if (whitelistedProtocols.includes(url.protocol)) {
1020
await shell.openExternal(url.href);
1121
} else {
1222
// For security, indirect links to non-whitelisted protocols

0 commit comments

Comments
 (0)