From 8a37b92bc83db229a788008c5a6a68cf51216ed2 Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Sat, 14 Aug 2021 14:52:24 +0000 Subject: Refactoring: Url helpers (#1789) These changes are mainly to ensure that 'shell.open*' invocations are only in a single file. * Moved 'openPath' into the 'url-helpers' file. * Extract 'openExternalUrl' into a common location in 'url-helpers' This is done so that we can then apply vetting rules to ensure that there is no security concern as described in https://benjamin-altpeter.de/shell-openexternal-dangers/ --- src/stores/AppStore.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/stores') diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 72ddc2927..9c8cce679 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -1,4 +1,4 @@ -import { ipcRenderer, shell } from 'electron'; +import { ipcRenderer } from 'electron'; import { app, screen, @@ -33,7 +33,7 @@ import { getServiceIdsFromPartitions, removeServicePartitionDirectory, } from '../helpers/service-helpers'; -import { isValidExternalURL } from '../helpers/url-helpers'; +import { openExternalUrl } from '../helpers/url-helpers'; import { sleep } from '../helpers/async-helpers'; const debug = require('debug')('Ferdi:AppStore'); @@ -388,13 +388,9 @@ export default class AppStore extends Store { } } + // Ideally(?) this should be merged with the 'shell-helpers' functionality @action _openExternalUrl({ url }) { - const parsedUrl = new URL(url); - debug('open external url', parsedUrl); - - if (isValidExternalURL(url)) { - shell.openExternal(url); - } + openExternalUrl(new URL(url)); } @action _checkForUpdates() { -- cgit v1.2.3-70-g09d2