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/components/ui | |
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/components/ui')
-rw-r--r-- | src/components/ui/Link.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/components/ui/Link.js b/src/components/ui/Link.js index fd14b7018..003211e5c 100644 --- a/src/components/ui/Link.js +++ b/src/components/ui/Link.js | |||
@@ -1,4 +1,3 @@ | |||
1 | import { shell } from 'electron'; | ||
2 | import React, { Component } from 'react'; | 1 | import React, { Component } from 'react'; |
3 | import PropTypes from 'prop-types'; | 2 | import PropTypes from 'prop-types'; |
4 | import { inject, observer } from 'mobx-react'; | 3 | import { inject, observer } from 'mobx-react'; |
@@ -7,15 +6,18 @@ import classnames from 'classnames'; | |||
7 | 6 | ||
8 | import { oneOrManyChildElements } from '../../prop-types'; | 7 | import { oneOrManyChildElements } from '../../prop-types'; |
9 | import { matchRoute } from '../../helpers/routing-helpers'; | 8 | import { matchRoute } from '../../helpers/routing-helpers'; |
9 | import { openExternalUrl } from '../../helpers/url-helpers'; | ||
10 | 10 | ||
11 | // TODO: create container component for this component | 11 | // TODO: create container component for this component |
12 | export default @inject('stores') @observer class Link extends Component { | 12 | export default @inject('stores') @observer class Link extends Component { |
13 | onClick(e) { | 13 | onClick(e) { |
14 | if (this.props.disabled) e.preventDefault(); | 14 | if (this.props.disabled) { |
15 | else if (this.props.target === '_blank') { | ||
16 | e.preventDefault(); | 15 | e.preventDefault(); |
17 | shell.openExternal(this.props.to); | 16 | } else if (this.props.target === '_blank') { |
17 | e.preventDefault(); | ||
18 | openExternalUrl(this.props.to, true); | ||
18 | } | 19 | } |
20 | // Note: if neither of the above, then let the other onClick handlers process it | ||
19 | } | 21 | } |
20 | 22 | ||
21 | render() { | 23 | render() { |