Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Remove preload.js path verification #138

Merged
merged 1 commit into from
Jun 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions electron/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,9 @@ function createWindow () {
mainWindow.webContents.on('will-attach-webview', (event, webPreferences, params) => {
// Strip away inline preload scripts, ours is at preloadURL
delete webPreferences.preload;
// Verify the location of our prelaod script is legitimate (unless uiDev has been passed)
if (webPreferences.preloadURL !== encodeURI(url.format({
pathname: path.join(__dirname, 'preload.js'),
protocol: 'file:',
slashes: true
})) && !cli.uiDev) {
throw new Error(`Unknown preload.js is being injected, quitting for security reasons. ${webPreferences.preloadURL}`);
}

// TODO Verify that the location of webPreferences.preloadURL is:
// `file://path/to/app.asar/.build/preload.js`

// Disable Node.js integration
webPreferences.nodeIntegration = false;
Expand Down