Skip to content
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,11 +3,21 @@ import fs from "node:fs";
import os from "node:os";
import path from "node:path";

import * as ConfigUtil from "./config-util.ts";
import {Html, html} from "./html.ts";
import * as t from "./translation-util.ts";

/* Fetches the current protocolLaunchers from settings.json */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protocolLaunchers doesn't seem like a noun. I don't think this comment is needed, since it is clear from using ConfigUtil.getConfigItem( that we are fetching 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can separate this using a comma?

```

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file-in -> file in


## 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add or modify -> To modify


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

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