mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: enforce parent-child relationship in custom postMessage() handler (#21529)
This commit is contained in:
committed by
Shelley Vohr
parent
8c531ed424
commit
32aca15962
@@ -317,6 +317,11 @@ ipcMainInternal.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function
|
||||
// The W3C does not seem to have word on how postMessage should work when the
|
||||
// origins do not match, so we do not do |canAccessWindow| check here since
|
||||
// postMessage across origins is useful and not harmful.
|
||||
if (!isRelatedWindow(event.sender, guestContents)) {
|
||||
console.error(`Blocked ${event.sender.getURL()} from calling postMessage.`)
|
||||
return
|
||||
}
|
||||
|
||||
if (targetOrigin === '*' || isSameOrigin(guestContents.getURL(), targetOrigin)) {
|
||||
const sourceId = event.sender.id
|
||||
guestContents._sendInternal('ELECTRON_GUEST_WINDOW_POSTMESSAGE', sourceId, message, sourceOrigin)
|
||||
|
||||
Reference in New Issue
Block a user