Skip to content

Exposing Whitelisted Protocols to User Settings #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.ts";
import {html} from "./html.ts";

/* 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
35 changes: 35 additions & 0 deletions docs/howto/customize-link-protocols.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Customizing Link Protocols

The Zulip app supports opening certain link protocols directly in their associated system applications. These are known as **whitelisted protocols**.

## Default Whitelisted Protocols

By default, the following protocols are whitelisted:

```
http https mailto tel sip
```

Links using these protocols are opened directly by the system.

All other protocols are considered potentially unsafe and are therefore opened indirectly—through a local HTML file—in your default web browser.

## Extending the Whitelisted Protocols

It is possible to customize the list of whitelisted protocols by editing the `settings.json` file located at: `userdata/Zulip/config/settings.json`

To add or modify the list, the `whitelistedProtocols` key can be updated. For example:

```json
{
...
"whitelistedProtocols": [
"http:",
"https:",
"mailto:"
]
...
}
```

Note: Each protocol should include the trailing colon (:), e.g., "mailto:" instead of "mailto".