1
1
Fork 1

Fix image uploads being perfectly white when canvas read access is blocked (#11499)

Fixes #11496
Dieser Commit ist enthalten in:
ThibG 2019-08-06 12:08:19 +02:00 committet von Eugen Rochko
Ursprung cec93c35d8
Commit c69f190af9
1 geänderte Dateien mit 8 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -67,6 +67,14 @@ const processImage = (img, { width, height, orientation, type = 'image/png' }) =
context.drawImage(img, 0, 0, width, height);
// The Tor Browser and maybe other browsers may prevent reading from canvas
// and return an all-white image instead. Assume reading failed if the resized
// image is perfectly white.
const imageData = context.getImageData(0, 0, width, height);
if (imageData.every(value => value === 255)) {
throw 'Failed to read from canvas';
}
canvas.toBlob(resolve, type);
});