fix: ELECTRON-1505 (Prevent opening links longer than 2083) (#776)

* ELECTRON-1505 - Prevent opening links longer than 2083

* ELECTRON-1505 - Prevent opening links longer than 2083
This commit is contained in:
Kiran Niranjan 2019-08-30 16:01:15 +05:30 committed by Vishwas Shashidhar
parent 82cfbb1de0
commit 0902523c03
2 changed files with 9 additions and 1 deletions

View File

@ -193,9 +193,13 @@ export const handleChildWindow = (webContents: WebContents): void => {
}
});
} else {
event.preventDefault();
if (newWinUrl && newWinUrl.length > 2083) {
logger.info(`child-window-handler: new window url length is greater than 2083, not performing any action!`);
return;
}
logger.info(`child-window-handler: new window url is ${newWinUrl} which is not of the same host,
so opening it in the default browser!`);
event.preventDefault();
windowHandler.openUrlInDefaultBrowser(newWinUrl);
}
};

View File

@ -41,6 +41,10 @@ class ProtocolHandler {
* @param isAppRunning {Boolean} - whether the application is running
*/
public sendProtocol(url: string, isAppRunning: boolean = true): void {
if (url && url.length > 2083) {
logger.info(`protocol-handler: protocol handler url length is greater than 2083, not performing any action!`);
return;
}
logger.info(`protocol handler: processing protocol request for the url ${url}!`);
if (!this.preloadWebContents || !isAppRunning) {
logger.info(`protocol handler: app was started from the protocol request. Caching the URL ${url}!`);