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/index.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index f6573d8f5..563ad08ed 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ /* eslint-disable import/first */ -import { app, BrowserWindow, shell, ipcMain, session } from 'electron'; +import { app, BrowserWindow, ipcMain, session } from 'electron'; import { emptyDirSync, ensureFileSync } from 'fs-extra'; import { join } from 'path'; @@ -34,7 +34,7 @@ import { appId } from './package.json'; // eslint-disable-line import/no-unresol import './electron/exception'; import { asarPath } from './helpers/asar-helpers'; -import { isValidExternalURL } from './helpers/url-helpers'; +import { openExternalUrl } from './helpers/url-helpers'; import userAgent from './helpers/userAgent-helpers'; const debug = require('debug')('Ferdi:App'); @@ -344,10 +344,7 @@ const createWindow = () => { mainWindow.webContents.on('new-window', (e, url) => { debug('Open url', url); e.preventDefault(); - - if (isValidExternalURL(url)) { - shell.openExternal(url); - } + openExternalUrl(url); }); if (settings.get('startMinimized')) { -- cgit v1.2.3-70-g09d2