From 6edcbb34588055c94dd278ac3bb98d3e85eca8a5 Mon Sep 17 00:00:00 2001 From: "Jonas_sorgenfrei@yahoo.de" Date: Fri, 27 Dec 2024 14:19:33 +0100 Subject: [PATCH] implementing whitelisted protocols to allow configuring linkifiers in the settings.json --- app/common/config-schemata.ts | 1 + app/common/link-util.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/common/config-schemata.ts b/app/common/config-schemata.ts index e2db7b80f..5cab99305 100644 --- a/app/common/config-schemata.ts +++ b/app/common/config-schemata.ts @@ -36,6 +36,7 @@ export const configSchemata = { useManualProxy: z.boolean(), useProxy: z.boolean(), useSystemProxy: z.boolean(), + whitelistedProtocols: z.string().array(), }; export const enterpriseConfigSchemata = { diff --git a/app/common/link-util.ts b/app/common/link-util.ts index bfd2157fa..87305e5e7 100644 --- a/app/common/link-util.ts +++ b/app/common/link-util.ts @@ -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 { - 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