[MM-21075] Prevent known teams to open in a new app window (#1130)
* [MM-21075] prevent known teams to open a new window * improve naming * allow anything that is not a team to open a window
This commit is contained in:
16
src/main.js
16
src/main.js
@@ -432,6 +432,10 @@ function handleAppWebContentsCreated(dc, contents) {
|
|||||||
log.info(`Untrusted popup window blocked: ${url}`);
|
log.info(`Untrusted popup window blocked: ${url}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isTeamUrl(url) === true) {
|
||||||
|
log.info(`${url} is a known team, preventing to open a new window`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (popupWindow && popupWindow.getURL() === url) {
|
if (popupWindow && popupWindow.getURL() === url) {
|
||||||
log.info(`Popup window already open at provided url: ${url}`);
|
log.info(`Popup window already open at provided url: ${url}`);
|
||||||
return;
|
return;
|
||||||
@@ -852,6 +856,18 @@ function parseURL(url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isTeamUrl(url) {
|
||||||
|
const parsedURL = parseURL(url);
|
||||||
|
if (!parsedURL) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (isCustomLoginURL(parsedURL)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const nonTeamUrlPaths = ['plugins', 'signup', 'login', 'admin', 'channel', 'post', 'api', 'oauth'];
|
||||||
|
return !(nonTeamUrlPaths.some((testPath) => parsedURL.pathname.toLowerCase().startsWith(`/${testPath}/`)));
|
||||||
|
}
|
||||||
|
|
||||||
function isTrustedURL(url) {
|
function isTrustedURL(url) {
|
||||||
const parsedURL = parseURL(url);
|
const parsedURL = parseURL(url);
|
||||||
if (!parsedURL) {
|
if (!parsedURL) {
|
||||||
|
Reference in New Issue
Block a user