perf: improved ipc validation on Linux

This commit is contained in:
fabio286 2023-09-13 16:30:08 +02:00
parent 13592425af
commit 9de5f67d18
2 changed files with 6 additions and 2 deletions

View File

@ -2,10 +2,14 @@ import { WebFrameMain } from 'electron';
import * as path from 'path';
const isDevelopment = process.env.NODE_ENV !== 'production';
const isWindows = process.platform === 'win32';
const indexPath = path.resolve(__dirname, 'index.html').split(path.sep).join('/');
export function validateSender (frame: WebFrameMain) {
const frameUrl = new URL(frame.url);
if ((isDevelopment && frameUrl.host === 'localhost:9080') || frameUrl.href.replace('file:///', '').replace('file://localhost', '') === indexPath) return true;
const prefix = isWindows ? 'file:///' : 'file://';
const framePath = frameUrl.href.replace(prefix, '');
if ((isDevelopment && frameUrl.host === 'localhost:9080') || framePath === indexPath) return true;
return false;
}

View File

@ -3,7 +3,7 @@ import * as Store from 'electron-store';
import { defineStore } from 'pinia';
const persistentStore = new Store({ name: 'settings' });
export type UpdateStatus = 'noupdate' | 'available' | 'checking' | 'nocheck' | 'downloading' | 'downloaded' | 'disabled';
export type UpdateStatus = 'noupdate' | 'available' | 'checking' | 'nocheck' | 'downloading' | 'downloaded' | 'disabled' | 'link';
export const useApplicationStore = defineStore('application', {
state: () => ({