Skip to content

Commit

Permalink
[MM-50948] Prevent popup windows from navigating outside of the plugi…
Browse files Browse the repository at this point in the history
…n/managed resource URLs (#2580)
  • Loading branch information
devinbinnie committed Mar 6, 2023
1 parent 55529a9 commit 3225076
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/views/webContentEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ export class WebContentsEventManager {
spellcheck: (typeof spellcheck === 'undefined' ? true : spellcheck),
},
});
this.popupWindow.webContents.on('will-redirect', (event, url) => {
const parsedURL = urlUtils.parseURL(url);
if (!parsedURL) {
event.preventDefault();
return;
}

if (urlUtils.isInternalURL(serverURL, parsedURL) && !urlUtils.isPluginUrl(serverURL, parsedURL) && !urlUtils.isManagedResource(serverURL, parsedURL)) {
event.preventDefault();
}
});
this.popupWindow.webContents.setWindowOpenHandler(this.denyNewWindow);
this.popupWindow.once('ready-to-show', () => {
this.popupWindow!.show();
Expand Down

0 comments on commit 3225076

Please sign in to comment.