mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 23:37:18 +00:00
Prevent exernal resources from being loaded by the WebView (#456)
If a user drags and drops an image, an HTML file, or other resource the WebView understands, Electron will navigate away from the application and load it up in the WebView, making the application unusable unless the user restarts it. Fixes: https://github.com/resin-io/etcher/issues/430 Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
parent
6c936a5192
commit
0c94de7fcf
@ -81,6 +81,13 @@ electron.app.on('ready', function() {
|
||||
electron.globalShortcut.unregisterAll();
|
||||
});
|
||||
|
||||
// Prevent external resources from being loaded (like images)
|
||||
// when dropping them on the WebView.
|
||||
// See https://github.com/electron/electron/issues/5919
|
||||
mainWindow.webContents.on('will-navigate', function(event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
mainWindow.loadURL(`file://${path.join(__dirname, 'index.html')}`);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user