fix: better window hierarchy checks
This commit is contained in:
parent
decbca734f
commit
8e368a046d
1 changed files with 9 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
|
const nodeUrl = require('url');
|
||||||
const { BrowserWindow } = electron;
|
const { BrowserWindow } = electron;
|
||||||
const { isSameOrigin } = process.electronBinding('v8_util');
|
const { isSameOrigin } = process.electronBinding('v8_util');
|
||||||
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal');
|
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal');
|
||||||
|
@ -181,9 +182,8 @@ const isNodeIntegrationEnabled = function (sender) {
|
||||||
|
|
||||||
// Checks whether |sender| can access the |target|:
|
// Checks whether |sender| can access the |target|:
|
||||||
const canAccessWindow = function (sender, target) {
|
const canAccessWindow = function (sender, target) {
|
||||||
return isChildWindow(sender, target) ||
|
return isScriptableWindow(sender, target) ||
|
||||||
isScriptableWindow(sender, target) ||
|
(isChildWindow(sender, target) && isNodeIntegrationEnabled(sender));
|
||||||
isNodeIntegrationEnabled(sender);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Routed window.open messages with raw options
|
// Routed window.open messages with raw options
|
||||||
|
@ -191,6 +191,12 @@ ipcMainInternal.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, url, fra
|
||||||
if (url == null || url === '') url = 'about:blank';
|
if (url == null || url === '') url = 'about:blank';
|
||||||
if (frameName == null) frameName = '';
|
if (frameName == null) frameName = '';
|
||||||
if (features == null) features = '';
|
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 = {};
|
const options = {};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue