thumbnail: Stop applying MAX_EMOJI_GIF_FILE_SIZE_BYTES before resizing.

b14a33c659 attempted to make the 128k limit apply _after_ resizing,
but left this check, which examines the pre-resized image size.
This commit is contained in:
Alex Vandiver 2024-07-12 03:40:46 +00:00 committed by Tim Abbott
parent 54f2fabac0
commit 544d3df057
2 changed files with 0 additions and 10 deletions

View File

@ -133,9 +133,6 @@ def resize_logo(image_data: bytes) -> bytes:
def resize_emoji(
image_data: bytes, emoji_file_name: str, size: int = DEFAULT_EMOJI_SIZE
) -> Tuple[bytes, Optional[bytes]]:
if len(image_data) > MAX_EMOJI_GIF_FILE_SIZE_BYTES:
raise BadImageError(_("Image size exceeds limit."))
# Square brackets are used for providing options to libvips' save
# operation; the extension on the filename comes from reversing
# the content-type, which removes most of the attacker control of

View File

@ -134,13 +134,6 @@ class EmojiTest(ZulipTestCase):
with self.assertRaises(BadImageError):
resize_emoji(corrupted_img_data, "corrupt.gif")
def test_resize_too_large_pre_resize(self) -> None:
"""An image that is too many bytes pre-resize is an error"""
animated_large_img_data = read_test_image_file("animated_large_img.gif")
with patch("zerver.lib.thumbnail.MAX_EMOJI_GIF_FILE_SIZE_BYTES", 1024):
with self.assertRaises(BadImageError):
resize_emoji(animated_large_img_data, "animated_large_img.gif", size=50)
def test_resize_too_many_pixels(self) -> None:
"""An image file with too many pixels is not resized"""
with patch("zerver.lib.thumbnail.IMAGE_BOMB_TOTAL_PIXELS", 100):