diff options
author | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-08-14 14:52:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-14 20:22:24 +0530 |
commit | 8a37b92bc83db229a788008c5a6a68cf51216ed2 (patch) | |
tree | 1929798a3aa4089203668bd2b93dba497363eb5a /src/stores | |
parent | New Crowdin updates (#1786) (diff) | |
download | ferdium-app-8a37b92bc83db229a788008c5a6a68cf51216ed2.tar.gz ferdium-app-8a37b92bc83db229a788008c5a6a68cf51216ed2.tar.zst ferdium-app-8a37b92bc83db229a788008c5a6a68cf51216ed2.zip |
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/
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 12 |
1 files changed, 4 insertions, 8 deletions
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 @@ | |||
1 | import { ipcRenderer, shell } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import { | 2 | import { |
3 | app, | 3 | app, |
4 | screen, | 4 | screen, |
@@ -33,7 +33,7 @@ import { | |||
33 | getServiceIdsFromPartitions, | 33 | getServiceIdsFromPartitions, |
34 | removeServicePartitionDirectory, | 34 | removeServicePartitionDirectory, |
35 | } from '../helpers/service-helpers'; | 35 | } from '../helpers/service-helpers'; |
36 | import { isValidExternalURL } from '../helpers/url-helpers'; | 36 | import { openExternalUrl } from '../helpers/url-helpers'; |
37 | import { sleep } from '../helpers/async-helpers'; | 37 | import { sleep } from '../helpers/async-helpers'; |
38 | 38 | ||
39 | const debug = require('debug')('Ferdi:AppStore'); | 39 | const debug = require('debug')('Ferdi:AppStore'); |
@@ -388,13 +388,9 @@ export default class AppStore extends Store { | |||
388 | } | 388 | } |
389 | } | 389 | } |
390 | 390 | ||
391 | // Ideally(?) this should be merged with the 'shell-helpers' functionality | ||
391 | @action _openExternalUrl({ url }) { | 392 | @action _openExternalUrl({ url }) { |
392 | const parsedUrl = new URL(url); | 393 | openExternalUrl(new URL(url)); |
393 | debug('open external url', parsedUrl); | ||
394 | |||
395 | if (isValidExternalURL(url)) { | ||
396 | shell.openExternal(url); | ||
397 | } | ||
398 | } | 394 | } |
399 | 395 | ||
400 | @action _checkForUpdates() { | 396 | @action _checkForUpdates() { |