zulip/zerver
Alex Vandiver 96a5fa9d78 upload: Fix resizing non-animated images.
5dab6e9d31 began honoring the list of disposals for every frame.
Unfortunately, passing a list of disposals for a non-animated image
raises an exception:
```
  File "zerver/lib/upload.py", line 212, in resize_emoji
    image_data = resize_gif(im, size)
  File "zerver/lib/upload.py", line 165, in resize_gif
    frames[0].save(
  File "[...]/PIL/Image.py", line 2212, in save
    save_handler(self, fp, filename)
  File "[...]/PIL/GifImagePlugin.py", line 605, in _save
    _write_single_frame(im, fp, palette)
  File "[...]/PIL/GifImagePlugin.py", line 506, in _write_single_frame
    _write_local_header(fp, im, (0, 0), flags)
  File "[...]/PIL/GifImagePlugin.py", line 647, in _write_local_header
    disposal = int(im.encoderinfo.get("disposal", 0))
TypeError: int() argument must be a string, a bytes-like object or a
number, not 'list'
```

`check_add_realm_emoji` calls this as:

```
    try:
        is_animated = upload_emoji_image(image_file, emoji_file_name, a
uthor)
        emoji_uploaded_successfully = True
    finally:
        if not emoji_uploaded_successfully:
            realm_emoji.delete()
            return None
        # ...
```

This is equivalent to dropping _all_ exceptions silently.  As such,
Zulip has silently rejected all non-animated images larger than 64x64
since 5dab6e9d31.

Adjust to only pass a single disposal if there are no additional
frames.  Add a test for non-animated images, which requires also
fixing the incidental bug that all GIF images were being recorded as
animated, regardless of if they had more than 1 frame or not.
2022-02-17 12:19:47 -08:00
..
data_import docs: Fix many spelling mistakes. 2022-02-07 18:51:06 -08:00
integration_fixtures/nagios tests: Add a test for fixtures for non-webhook integrations. 2021-04-28 08:16:51 -07:00
lib upload: Fix resizing non-animated images. 2022-02-17 12:19:47 -08:00
management management: Run log_email_config_errors in send_test_email command. 2022-02-10 10:55:49 -08:00
migrations migrations: Don't push events to deferred_work queue if TEST_SUITE. 2022-02-14 16:05:25 -08:00
openapi docs: Fix many spelling mistakes. 2022-02-07 18:51:06 -08:00
tests upload: Fix resizing non-animated images. 2022-02-17 12:19:47 -08:00
tornado docs: Fix many spelling mistakes. 2022-02-07 18:51:06 -08:00
views auth: Remove unused kwargs for saml_sp_metadata. 2022-02-16 13:01:34 -08:00
webhooks docs: Fix many spelling mistakes. 2022-02-07 18:51:06 -08:00
worker emoji: Add migration to reupload all RealmEmoji and ensure .author. 2022-02-10 17:45:31 -08:00
__init__.py django: Upgrade Zulip to Django 3.2 LTS. 2021-05-03 08:36:22 -07:00
apps.py caching: Make sender type optional for flush_cache. 2021-07-26 14:48:07 -07:00
context_processors.py home: Simplify and comment terms of service notice implementation. 2022-02-04 15:48:38 -08:00
decorator.py decorator: Enable web-public view for production. 2022-02-16 13:25:53 -08:00
filters.py typing: Fix function signatures. 2021-08-20 05:54:19 -07:00
forms.py python: Replace deprecated jinja2.utils.Markup with markupsafe.Markup. 2022-01-13 14:22:48 -08:00
logging_handlers.py python: Replace universal_newlines with text. 2022-01-23 22:16:01 -08:00
middleware.py docs: Fix many spelling mistakes. 2022-02-07 18:51:06 -08:00
models.py pricing: Replace "Zulip Standard" with "Zulip Cloud Standard". 2022-02-09 11:00:24 -08:00
signals.py python: Convert deprecated Django ugettext alias to gettext. 2021-04-15 18:01:34 -07:00