From 4de01212a49e3957319e769622bc8f2da10494bb Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 21 Jul 2020 22:56:51 -0400 Subject: [PATCH] Fix detection of some JPEG images without JFIF or Exif info Closes #5143 --- discord/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/utils.py b/discord/utils.py index a6f3897e7..c1d6c69e9 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -299,7 +299,7 @@ def _get_as_snowflake(data, key): def _get_mime_type_for_image(data): if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'): return 'image/png' - elif data[6:10] in (b'JFIF', b'Exif'): + elif data[0:3] == b'\xff\xd8\xff' or data[6:10] in (b'JFIF', b'Exif'): return 'image/jpeg' elif data.startswith((b'\x47\x49\x46\x38\x37\x61', b'\x47\x49\x46\x38\x39\x61')): return 'image/gif'