aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <s@saghul.net>2020-06-04 09:54:18 +0200
committerSaúl Ibarra Corretgé <s@saghul.net>2020-06-04 10:32:03 +0200
commit962470d97e8faefa5728ff4c324ce387cfd456e0 (patch)
tree7fdd52d4cf8b7614beeaa93b5ebc65881e454382 /app
parent27fc58f9277f8fb578e857c77c04fcb0fe80bb19 (diff)
Restrict URLs which can be opened in an external browser
Diffstat (limited to 'app')
-rw-r--r--app/features/utils/functions.js2
-rw-r--r--app/preload/preload.js28
2 files changed, 27 insertions, 3 deletions
diff --git a/app/features/utils/functions.js b/app/features/utils/functions.js
index 50b10a2..4c7bf5a 100644
--- a/app/features/utils/functions.js
+++ b/app/features/utils/functions.js
@@ -52,5 +52,5 @@ export function normalizeServerURL(url: string) {
* @returns {void}
*/
export function openExternalLink(link: string) {
- window.jitsiNodeAPI.shellOpenExternal(link);
+ window.jitsiNodeAPI.openExternalLink(link);
}
diff --git a/app/preload/preload.js b/app/preload/preload.js
index 16cf79a..cbe9aab 100644
--- a/app/preload/preload.js
+++ b/app/preload/preload.js
@@ -1,13 +1,37 @@
const createElectronStorage = require('redux-persist-electron-storage');
const { shell } = require('electron');
const os = require('os');
+const url = require('url');
const jitsiMeetElectronUtils = require('jitsi-meet-electron-utils');
+
+const protocolRegex = /^https?:/i;
+
+/**
+ * Opens the given link in an external browser.
+ *
+ * @param {string} link - The link (URL) that should be opened in the external browser.
+ * @returns {void}
+ */
+function openExternalLink(link) {
+ let u;
+
+ try {
+ u = url.parse(link);
+ } catch (e) {
+ return;
+ }
+
+ if (protocolRegex.test(u.protocol)) {
+ shell.openExternal(link);
+ }
+}
+
+
window.jitsiNodeAPI = {
createElectronStorage,
osUserInfo: os.userInfo,
- shellOpenExternal: shell.openExternal,
+ openExternalLink,
jitsiMeetElectronUtils
};
-