zulip / zulip-desktop

Zulip Desktop client for Mac, Windows and Linux.
https://zulip.com/apps
Apache License 2.0
845 stars 427 forks source link

LinkUtils custom application launcher protocols #1284

Open jonassorgenfrei opened 1 year ago

jonassorgenfrei commented 1 year ago

Hey,

we are using Zulip and are having a problem for some of our custom launcher we'd link to linkify. The links are :// unfortunatly this will always be opened in the browser as the custom protocol is not part of the list. ["http:", "https:", "mailto:"]

Would there be an option to ad custom protocol launcher to the settings which will look like: "protocolLaunchers": { "": "mylauncher", }

In https://github.com/zulip/zulip-desktop/blob/main/app/common/link-util.ts

The pseudo-code my look like:

...
if (["http:", "https:", "mailto:"].includes(url.protocol)) {
    await shell.openExternal(url.href);
} elif (procolLaunchers.includes(url.protocol)) {
    executable = procolLaunchers[url.protocol]
    command = url.pathname.replace(/^\/+/g, "") + url.search + url.hash

    await shell.openExternal(executable + " " + command );
}
else
....

This is an option which might gives the opertunity that users can create clickable links which e.g. open files in applications while keeping the secruity menitoned in: // For security, indirect links to non-whitelisted protocols // through a real web browser via a local HTML file.

As the protocolLaunchers can be configured manually.

What do you think about this, happy to help/cotnribute this with a PR if it's cool :)

jonassorgenfrei commented 1 year ago

Actually i found out that it's way easier to just expose the whitelistedProtocol list, which i will do in a PR!