Fixed: Unable to disable WebSecurity along with NodeIntegration enabled #389

This commit is contained in:
Gregor Biswanger
2020-04-24 00:59:38 +02:00
parent a619b6e5c9
commit 71955b9181
3 changed files with 8 additions and 23 deletions

View File

@@ -161,17 +161,11 @@ module.exports = (socket, app) => {
electronSocket.emit('browserWindow-new-window-for-tab' + id);
});
});
function hasOwnChildreen(obj, ...childNames) {
for (let i = 0; i < childNames.length; i++) {
if (!obj || !obj.hasOwnProperty(childNames[i])) {
return false;
}
obj = obj[childNames[i]];
}
return true;
}
socket.on('createBrowserWindow', (options, loadUrl) => {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
if (options.webPreferences && !('nodeIntegration' in options.webPreferences)) {
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true } };
}
else if (!options.webPreferences) {
options = { ...options, webPreferences: { nodeIntegration: true } };
}
window = new electron_1.BrowserWindow(options);

File diff suppressed because one or more lines are too long

View File

@@ -192,19 +192,10 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
});
});
function hasOwnChildreen(obj, ...childNames) {
for (let i = 0; i < childNames.length; i++) {
if (!obj || !obj.hasOwnProperty(childNames[i])) {
return false;
}
obj = obj[childNames[i]];
}
return true;
}
socket.on('createBrowserWindow', (options, loadUrl) => {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
if (options.webPreferences && !('nodeIntegration' in options.webPreferences)) {
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true } };
} else if (!options.webPreferences) {
options = { ...options, webPreferences: { nodeIntegration: true } };
}