From f0222b0101ea4a0bc1638da9d32e691959aca0ba Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Fri, 23 Feb 2018 17:01:16 +0530 Subject: [PATCH 1/2] ELECTRON-274: fix issue. --- js/windowMgr.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/windowMgr.js b/js/windowMgr.js index 3dc0a287..edb747ca 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -311,7 +311,7 @@ function doCreateMainWindow(initialUrl, initialBounds) { // open external links in default browser - a tag with href='_blank' or window.open mainWindow.webContents.on('new-window', function (event, newWinUrl, frameName, disposition, newWinOptions) { - + let newWinParsedUrl = getParsedUrl(newWinUrl); let mainWinParsedUrl = getParsedUrl(url); @@ -319,10 +319,11 @@ function doCreateMainWindow(initialUrl, initialBounds) { let mainWinHost = mainWinParsedUrl && mainWinParsedUrl.host; let emptyUrlString = 'about:blank'; - + let dispositionWhitelist = ['new-window', 'foreground-tab']; + // only allow window.open to succeed is if coming from same hsot, // otherwise open in default browser. - if (disposition === 'new-window' && ((newWinHost === mainWinHost) || newWinUrl === emptyUrlString)) { + if (((newWinHost === mainWinHost) || newWinUrl === emptyUrlString) && dispositionWhitelist.includes(disposition)) { // handle: window.open if (!frameName) { From de8d062f8c873db0d8d5a7e1d4212a0b2091200b Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Fri, 23 Feb 2018 17:15:31 +0530 Subject: [PATCH 2/2] ELECTRON-274: fix as per pr comments --- js/windowMgr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/windowMgr.js b/js/windowMgr.js index edb747ca..536bcb22 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -323,7 +323,7 @@ function doCreateMainWindow(initialUrl, initialBounds) { // only allow window.open to succeed is if coming from same hsot, // otherwise open in default browser. - if (((newWinHost === mainWinHost) || newWinUrl === emptyUrlString) && dispositionWhitelist.includes(disposition)) { + if ((newWinHost === mainWinHost || newWinUrl === emptyUrlString) && dispositionWhitelist.includes(disposition)) { // handle: window.open if (!frameName) {