Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Make sure BrowserWindow only loads whitelisted URLs
Browse files Browse the repository at this point in the history
Fix #445

Auditors: @bbondy
  • Loading branch information
diracdeltas committed Jan 30, 2016
1 parent 85bae78 commit 7e5dba3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,24 @@ const handleAppAction = (action) => {
'appState=' + encodeURIComponent(JSON.stringify(appState.toJS())) +
'&frames=' + encodeURIComponent(JSON.stringify(frames))

const devUrl = 'file://' + __dirname + '/../../app/index-dev.html?' + queryString
const prodUrl = 'file://' + __dirname + '/../../app/index.html?' + queryString
if (process.env.NODE_ENV === 'development') {
mainWindow.loadURL('file://' + __dirname + '/../../app/index-dev.html?' + queryString)
mainWindow.loadURL(devUrl)
// Prevent this window from loading non-whitelisted content
mainWindow.webContents.on('will-navigate', (e, url) => {
if (url !== devUrl) {
e.preventDefault()
}
})
} else {
mainWindow.loadURL('file://' + __dirname + '/../../app/index.html?' + queryString)
mainWindow.loadURL(prodUrl)
// Prevent this window from loading non-whitelisted content
mainWindow.webContents.on('will-navigate', (e, url) => {
if (url !== prodUrl) {
e.preventDefault()
}
})
}
appStore.emitChange()

Expand Down

1 comment on commit 7e5dba3

@bbondy
Copy link
Member

@bbondy bbondy commented on 7e5dba3 Jan 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome++

Please sign in to comment.