Harden Linux clipboard image paste and bump cinny.
Some checks failed
Build / increment-version (push) Successful in 13s
Build / prepare-release (push) Successful in 15s
Build / build-windows (push) Successful in 7m28s
Build / finalize-release (push) Has been cancelled
Build / build-linux (push) Has been cancelled

Require a real image/* clipboard format before treating paste as an image, and pick up firework confetti plus URL-paste fixes from cinny.
This commit is contained in:
2026-08-09 15:50:23 +10:00
parent fc5d498673
commit e917193b0d
2 changed files with 14 additions and 1 deletions

2
cinny

Submodule cinny updated: 8a68a1e30a...13523fea2b

View File

@@ -1278,11 +1278,24 @@ ipcMain.handle('open-external-url', async (event, url) => {
// Read clipboard image // Read clipboard image
ipcMain.handle('read-clipboard-image', async () => { ipcMain.handle('read-clipboard-image', async () => {
try { try {
// Extra Things: only trust an image when the clipboard actually advertises one.
// On Linux, readImage() can return a stale bitmap after copying plain text/URLs.
const formats = clipboard.availableFormats();
const hasImageFormat = formats.some((format) => format.startsWith('image/'));
if (!hasImageFormat) {
return { success: true, data: null };
}
const image = clipboard.readImage(); const image = clipboard.readImage();
if (image.isEmpty()) { if (image.isEmpty()) {
return { success: true, data: null }; return { success: true, data: null };
} }
const { width, height } = image.getSize();
if (width < 2 || height < 2) {
return { success: true, data: null };
}
// Convert to PNG base64 // Convert to PNG base64
const pngBuffer = image.toPNG(); const pngBuffer = image.toPNG();
const base64 = pngBuffer.toString('base64'); const base64 = pngBuffer.toString('base64');