fix(clipboard): route copy actions through Electron
Replace renderer clipboard calls with the validated main-process IPC writer for link names, URLs, package batches, backup keys, diagnostics, error details, and masked account identifiers. Raise the validated payload limit to one MiB so complete link packages copy without truncation while preserving empty and oversized input rejection.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
export const CLIPBOARD_WRITE_MAX_BYTES = 1024 * 1024;
|
||||
|
||||
export function validateClipboardWriteText(value: unknown): string {
|
||||
if (typeof value !== "string") {
|
||||
throw new Error("text muss ein String sein");
|
||||
}
|
||||
if (!value.trim()) {
|
||||
throw new Error("text darf nicht leer sein");
|
||||
}
|
||||
const bytes = Buffer.byteLength(value, "utf8");
|
||||
if (bytes > CLIPBOARD_WRITE_MAX_BYTES) {
|
||||
throw new Error(`text ist zu groß (max ${CLIPBOARD_WRITE_MAX_BYTES} Bytes)`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
+7
-13
@@ -24,6 +24,7 @@ import { assertTrustedIpcSender, type TrustedIpcOptions } from "./ipc-security";
|
||||
import { validateRealDebridLoginRequest } from "../shared/preload-api";
|
||||
import { migrateProductUserDataDirectory } from "./storage";
|
||||
import { forceDarkNativeTheme } from "./native-theme";
|
||||
import { validateClipboardWriteText } from "./clipboard-write";
|
||||
|
||||
forceDarkNativeTheme(nativeTheme);
|
||||
|
||||
@@ -42,8 +43,7 @@ function validatePlainObject(value: unknown, name: string): Record<string, unkno
|
||||
}
|
||||
|
||||
const IMPORT_QUEUE_MAX_BYTES = 10 * 1024 * 1024;
|
||||
const CLIPBOARD_WRITE_MAX_BYTES = 4096;
|
||||
const RENAME_PACKAGE_MAX_CHARS = 240;
|
||||
const RENAME_PACKAGE_MAX_CHARS = 240;
|
||||
const RESETTABLE_PROVIDER_KEYS = new Set<DebridProvider>([
|
||||
"realdebrid",
|
||||
"megadebrid-api",
|
||||
@@ -636,17 +636,11 @@ function registerIpcHandlers(): void {
|
||||
controller.updateSettings({ clipboardWatch: next });
|
||||
updateClipboardWatcher();
|
||||
return next;
|
||||
});
|
||||
handleTrusted(IPC_CHANNELS.WRITE_CLIPBOARD_TEXT, (_event: IpcMainInvokeEvent, rawText: unknown) => {
|
||||
const text = validateString(rawText, "text");
|
||||
const bytes = Buffer.byteLength(text, "utf8");
|
||||
if (!text.trim()) {
|
||||
throw new Error("text darf nicht leer sein");
|
||||
}
|
||||
if (bytes > CLIPBOARD_WRITE_MAX_BYTES) {
|
||||
throw new Error(`text ist zu groß (max ${CLIPBOARD_WRITE_MAX_BYTES} Bytes)`);
|
||||
}
|
||||
try {
|
||||
});
|
||||
handleTrusted(IPC_CHANNELS.WRITE_CLIPBOARD_TEXT, (_event: IpcMainInvokeEvent, rawText: unknown) => {
|
||||
const text = validateClipboardWriteText(rawText);
|
||||
const bytes = Buffer.byteLength(text, "utf8");
|
||||
try {
|
||||
clipboard.writeText(text);
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user