Harden Linux clipboard image paste and bump cinny.
Some checks failed
Some checks failed
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:
@@ -1278,10 +1278,23 @@ ipcMain.handle('open-external-url', async (event, url) => {
|
||||
// Read clipboard image
|
||||
ipcMain.handle('read-clipboard-image', async () => {
|
||||
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();
|
||||
if (image.isEmpty()) {
|
||||
return { success: true, data: null };
|
||||
}
|
||||
|
||||
const { width, height } = image.getSize();
|
||||
if (width < 2 || height < 2) {
|
||||
return { success: true, data: null };
|
||||
}
|
||||
|
||||
// Convert to PNG base64
|
||||
const pngBuffer = image.toPNG();
|
||||
|
||||
Reference in New Issue
Block a user