fix for main origin 575a5adbeff0b46390fb08901c7166649255204c
This commit is contained in:
11 files changed
+1008
-703
No files matched your search
@@ -0,0 +1,48 @@
|
||||
diff --git a/fluxer_desktop/src/main/Window.ts b/fluxer_desktop/src/main/Window.ts
|
||||
index f537d89..b0a3454 100644
|
||||
--- a/fluxer_desktop/src/main/Window.ts
|
||||
+++ b/fluxer_desktop/src/main/Window.ts
|
||||
@@ -104,13 +104,22 @@ function getSanitizedPath(rawUrl: string): string | null {
|
||||
}
|
||||
}
|
||||
|
||||
+function isAllowedSsoNavigation(url: string): boolean {
|
||||
+ try {
|
||||
+ const origin = new URL(url).origin;
|
||||
+ return origin === 'https://sso.gandc.ru' || origin === 'https://ds.gandc.ru';
|
||||
+ } catch {
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
function preventUntrustedNavigation(event: Electron.Event, url: string, isMainFrame: boolean): void {
|
||||
if (isLocalAppURL(url) && !isLocalAppRendererDocumentURL(url)) {
|
||||
logger.warn('Blocked a navigation to a reserved local app path', {url, isMainFrame});
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
- if (isMainFrame && !isTrustedOrigin(url)) {
|
||||
+ if (isMainFrame && !isTrustedOrigin(url) && !isAllowedSsoNavigation(url)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
@@ -128,6 +137,9 @@ function attachChildWindowGuards(webContents: Electron.WebContents): void {
|
||||
webContents.on('will-frame-navigate', (event) => {
|
||||
preventUntrustedChildNavigation(event, event.url, event.isMainFrame);
|
||||
});
|
||||
+ webContents.on('will-redirect', (event, url, _isInPlace, isMainFrame) => {
|
||||
+ preventUntrustedChildNavigation(event, url, isMainFrame);
|
||||
+ });
|
||||
webContents.setWindowOpenHandler(({url}) => {
|
||||
openExternalDeduped(url).catch((error) => {
|
||||
log.warn('Failed to open external URL from a popout window-open:', error);
|
||||
@@ -1081,6 +1093,9 @@ export function createWindow(options: CreateWindowOptions = {}): BrowserWindow {
|
||||
webContents.on('will-frame-navigate', (event) => {
|
||||
preventUntrustedNavigation(event, event.url, event.isMainFrame);
|
||||
});
|
||||
+ webContents.on('will-redirect', (event, url, _isInPlace, isMainFrame) => {
|
||||
+ preventUntrustedNavigation(event, url, isMainFrame);
|
||||
+ });
|
||||
webContents.on('did-create-window', (window, details) => {
|
||||
if (
|
||||
details.frameName === THEME_STUDIO_POPOUT_WINDOW_NAME &&
|
||||
Reference in new issue
Block a user