Skip to content

Commit f21cca3

Browse files
authored
fix: Verify url protocol in window.open (#1723)
1 parent 20bfcbf commit f21cca3

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/ui/main/webviews.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,19 @@ export const attachGuestWebContentsEvents = (rootWindow: BrowserWindow): void =>
341341
newWindow.show();
342342
});
343343

344-
newWindow.loadURL(url, {
345-
httpReferrer: referrer,
346-
...postBody && {
347-
extraHeaders: `Content-Type: ${ postBody.contentType }; boundary=${ postBody.boundary }`,
348-
postData: postBody.data as unknown as (UploadRawData[] | UploadBlob[] | UploadFile[]),
349-
},
344+
isProtocolAllowed(url).then((allowed) => {
345+
if (!allowed) {
346+
newWindow.destroy();
347+
return;
348+
}
349+
350+
newWindow.loadURL(url, {
351+
httpReferrer: referrer,
352+
...postBody && {
353+
extraHeaders: `Content-Type: ${ postBody.contentType }; boundary=${ postBody.boundary }`,
354+
postData: postBody.data as unknown as (UploadRawData[] | UploadBlob[] | UploadFile[]),
355+
},
356+
});
350357
});
351358

352359
event.newGuest = newWindow;

0 commit comments

Comments
 (0)