Skip to content

Commit

Permalink
implementing whitelisted protocols to allow configuring linkifiers in…
Browse files Browse the repository at this point in the history
… the settings.json
  • Loading branch information
jonassorgenfrei committed Dec 27, 2024
1 parent 13f3818 commit 6edcbb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/common/config-schemata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const configSchemata = {
useManualProxy: z.boolean(),
useProxy: z.boolean(),
useSystemProxy: z.boolean(),
whitelistedProtocols: z.string().array(),
};

export const enterpriseConfigSchemata = {
Expand Down
12 changes: 11 additions & 1 deletion app/common/link-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ import fs from "node:fs";
import os from "node:os";
import path from "node:path";

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

/* Fetches the current protocolLaunchers from settings.json */
const whitelistedProtocols = ConfigUtil.getConfigItem("whitelistedProtocols", [
"http:",
"https:",
"mailto:",
"tel:",
"sip:",
]);

export async function openBrowser(url: URL): Promise<void> {
if (["http:", "https:", "mailto:"].includes(url.protocol)) {
if (whitelistedProtocols.includes(url.protocol)) {
await shell.openExternal(url.href);
} else {
// For security, indirect links to non-whitelisted protocols
Expand Down

0 comments on commit 6edcbb3

Please sign in to comment.