Fix max size for animated stickers (#4625)

This commit is contained in:
Romain Ricard 2020-11-03 01:45:55 +01:00 committed by GitHub
parent 0626a94288
commit 4bb8ed0a3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -15,6 +15,7 @@ const { nativeTheme } = remote.require('electron');
const STICKER_SIZE = 512;
const MIN_STICKER_DIMENSION = 10;
const MAX_STICKER_DIMENSION = STICKER_SIZE;
const MAX_WEBP_STICKER_BYTE_LENGTH = 100 * 1024;
const MAX_ANIMATED_STICKER_BYTE_LENGTH = 300 * 1024;
window.ROOT_PATH = window.location.href.startsWith('file') ? '../../' : '/';
@ -128,6 +129,12 @@ window.processStickerImage = async path => {
})
.webp()
.toBuffer();
if (processedBuffer.byteLength > MAX_WEBP_STICKER_BYTE_LENGTH) {
throw processStickerError(
'Sticker file was too large',
'StickerCreator--Toasts--tooLarge'
);
}
}
return {

View File

@ -51,7 +51,7 @@ export const reset = createAction<void>('stickers/reset');
export const minStickers = 1;
export const maxStickers = 200;
export const maxByteSize = 100 * 1024;
export const maxByteSize = 300 * 1024;
interface StateStickerData {
readonly imageData?: StickerImageData;