summaryrefslogtreecommitdiffstats
path: root/src/webview
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-08-14 14:52:24 +0000
committerLibravatar GitHub <noreply@github.com>2021-08-14 20:22:24 +0530
commit8a37b92bc83db229a788008c5a6a68cf51216ed2 (patch)
tree1929798a3aa4089203668bd2b93dba497363eb5a /src/webview
parentNew Crowdin updates (#1786) (diff)
downloadferdium-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/webview')
-rw-r--r--src/webview/contextMenuBuilder.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/webview/contextMenuBuilder.js b/src/webview/contextMenuBuilder.js
index 602ce06f5..126fa4086 100644
--- a/src/webview/contextMenuBuilder.js
+++ b/src/webview/contextMenuBuilder.js
@@ -6,13 +6,12 @@
6 * 6 *
7 * Source: https://github.com/electron-userland/electron-spellchecker/blob/master/src/context-menu-builder.js 7 * Source: https://github.com/electron-userland/electron-spellchecker/blob/master/src/context-menu-builder.js
8 */ 8 */
9import { 9import { clipboard, ipcRenderer, nativeImage } from 'electron';
10 clipboard, ipcRenderer, nativeImage, shell,
11} from 'electron';
12import { Menu, MenuItem } from '@electron/remote'; 10import { Menu, MenuItem } from '@electron/remote';
13import { shortcutKey, isMac } from '../environment'; 11import { shortcutKey, isMac } from '../environment';
14 12
15import { SEARCH_ENGINE_NAMES, SEARCH_ENGINE_URLS } from '../config'; 13import { SEARCH_ENGINE_NAMES, SEARCH_ENGINE_URLS } from '../config';
14import { openExternalUrl } from '../helpers/url-helpers';
16 15
17const { URL } = require('url'); 16const { URL } = require('url');
18 17
@@ -170,7 +169,7 @@ module.exports = class ContextMenuBuilder {
170 const openLink = new MenuItem({ 169 const openLink = new MenuItem({
171 label: this.stringTable.openLinkUrl(), 170 label: this.stringTable.openLinkUrl(),
172 click: () => { 171 click: () => {
173 shell.openExternal(menuInfo.linkURL); 172 openExternalUrl(menuInfo.linkURL, true);
174 }, 173 },
175 }); 174 });
176 175
@@ -299,7 +298,7 @@ module.exports = class ContextMenuBuilder {
299 label: this.stringTable.searchWith({ searchEngine: SEARCH_ENGINE_NAMES[menuInfo.searchEngine] }), 298 label: this.stringTable.searchWith({ searchEngine: SEARCH_ENGINE_NAMES[menuInfo.searchEngine] }),
300 click: () => { 299 click: () => {
301 const url = SEARCH_ENGINE_URLS[menuInfo.searchEngine]({ searchTerm: encodeURIComponent(menuInfo.selectionText) }); 300 const url = SEARCH_ENGINE_URLS[menuInfo.searchEngine]({ searchTerm: encodeURIComponent(menuInfo.selectionText) });
302 shell.openExternal(url); 301 openExternalUrl(url, true);
303 }, 302 },
304 }); 303 });
305 304
@@ -555,7 +554,7 @@ module.exports = class ContextMenuBuilder {
555 label: this.stringTable.openInBrowser(), 554 label: this.stringTable.openInBrowser(),
556 enabled: true, 555 enabled: true,
557 click: () => { 556 click: () => {
558 shell.openExternal(menuInfo.pageURL); 557 openExternalUrl(menuInfo.pageURL, true);
559 }, 558 },
560 })); 559 }));
561 560