Skip to content

Commit

Permalink
fix: better window hierarchy checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Mar 23, 2020
1 parent 8e30e21 commit c16c4c2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/browser/guest-window-manager.js
@@ -1,6 +1,7 @@
'use strict';

const electron = require('electron');
const nodeUrl = require('url');
const { BrowserWindow } = electron;
const { isSameOrigin } = process.electronBinding('v8_util');
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal');
Expand Down Expand Up @@ -181,16 +182,21 @@ const isNodeIntegrationEnabled = function (sender) {

// Checks whether |sender| can access the |target|:
const canAccessWindow = function (sender, target) {
return isChildWindow(sender, target) ||
isScriptableWindow(sender, target) ||
isNodeIntegrationEnabled(sender);
return isScriptableWindow(sender, target) ||
(isChildWindow(sender, target) && isNodeIntegrationEnabled(sender));
};

// Routed window.open messages with raw options
ipcMainInternal.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, url, frameName, features) => {
if (url == null || url === '') url = 'about:blank';
if (frameName == null) frameName = '';
if (features == null) features = '';
const parsedSourceURL = nodeUrl.parse(event.sender.getURL());
const parsedTargetURL = nodeUrl.parse(url);
if (parsedTargetURL.protocol === 'file:' && parsedSourceURL.protocol !== 'file:') {
event.returnValue = null;
return;
}

const options = {};

Expand Down

0 comments on commit c16c4c2

Please sign in to comment.