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:
2
cinny
2
cinny
Submodule cinny updated: 8a68a1e30a...13523fea2b
@@ -1278,10 +1278,23 @@ 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();
|
||||||
|
|||||||
Reference in New Issue
Block a user