diff options
author | 2021-08-14 14:52:24 +0000 | |
---|---|---|
committer | 2021-08-14 20:22:24 +0530 | |
commit | 8a37b92bc83db229a788008c5a6a68cf51216ed2 (patch) | |
tree | 1929798a3aa4089203668bd2b93dba497363eb5a /src/lib | |
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/lib')
-rw-r--r-- | src/lib/Menu.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index e4056e536..d34cfc4e6 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -1,7 +1,5 @@ | |||
1 | import { clipboard, shell } from 'electron'; | 1 | import { clipboard } from 'electron'; |
2 | import { | 2 | import { app, Menu, dialog, systemPreferences } from '@electron/remote'; |
3 | app, Menu, dialog, systemPreferences, | ||
4 | } from '@electron/remote'; | ||
5 | import { autorun, observable } from 'mobx'; | 3 | import { autorun, observable } from 'mobx'; |
6 | import { defineMessages } from 'react-intl'; | 4 | import { defineMessages } from 'react-intl'; |
7 | import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; | 5 | import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; |
@@ -15,6 +13,7 @@ import { todoActions } from '../features/todos/actions'; | |||
15 | import { workspaceActions } from '../features/workspaces/actions'; | 13 | import { workspaceActions } from '../features/workspaces/actions'; |
16 | import { workspaceStore } from '../features/workspaces/index'; | 14 | import { workspaceStore } from '../features/workspaces/index'; |
17 | import apiBase, { termsBase } from '../api/apiBase'; | 15 | import apiBase, { termsBase } from '../api/apiBase'; |
16 | import { openExternalUrl } from '../helpers/url-helpers'; | ||
18 | 17 | ||
19 | const menuItems = defineMessages({ | 18 | const menuItems = defineMessages({ |
20 | edit: { | 19 | edit: { |
@@ -514,15 +513,15 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
514 | submenu: [ | 513 | submenu: [ |
515 | { | 514 | { |
516 | label: intl.formatMessage(menuItems.learnMore), | 515 | label: intl.formatMessage(menuItems.learnMore), |
517 | click() { shell.openExternal(LIVE_API_FERDI_WEBSITE); }, | 516 | click() { openExternalUrl(LIVE_API_FERDI_WEBSITE, true); }, |
518 | }, | 517 | }, |
519 | { | 518 | { |
520 | label: intl.formatMessage(menuItems.changelog), | 519 | label: intl.formatMessage(menuItems.changelog), |
521 | click() { shell.openExternal(`${GITHUB_FERDI_URL}/ferdi/blob/master/CHANGELOG.md`); }, | 520 | click() { openExternalUrl(`${GITHUB_FERDI_URL}/ferdi/blob/master/CHANGELOG.md`, true); }, |
522 | }, | 521 | }, |
523 | { | 522 | { |
524 | label: intl.formatMessage(menuItems.importExportData), | 523 | label: intl.formatMessage(menuItems.importExportData), |
525 | click() { shell.openExternal(apiBase(false)); }, | 524 | click() { openExternalUrl(apiBase(false), true); }, |
526 | enabled: !locked, | 525 | enabled: !locked, |
527 | }, | 526 | }, |
528 | { | 527 | { |
@@ -540,18 +539,18 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
540 | }, | 539 | }, |
541 | { | 540 | { |
542 | label: intl.formatMessage(menuItems.support), | 541 | label: intl.formatMessage(menuItems.support), |
543 | click() { shell.openExternal(`${LIVE_API_FERDI_WEBSITE}/contact`); }, | 542 | click() { openExternalUrl(`${LIVE_API_FERDI_WEBSITE}/contact`, true); }, |
544 | }, | 543 | }, |
545 | { | 544 | { |
546 | type: 'separator', | 545 | type: 'separator', |
547 | }, | 546 | }, |
548 | { | 547 | { |
549 | label: intl.formatMessage(menuItems.tos), | 548 | label: intl.formatMessage(menuItems.tos), |
550 | click() { shell.openExternal(`${termsBase()}/terms`); }, | 549 | click() { openExternalUrl(`${termsBase()}/terms`, true); }, |
551 | }, | 550 | }, |
552 | { | 551 | { |
553 | label: intl.formatMessage(menuItems.privacy), | 552 | label: intl.formatMessage(menuItems.privacy), |
554 | click() { shell.openExternal(`${termsBase()}/privacy`); }, | 553 | click() { openExternalUrl(`${termsBase()}/privacy`, true); }, |
555 | }, | 554 | }, |
556 | ], | 555 | ], |
557 | }, | 556 | }, |