Browse Source

Allow uploading of GIFs for users.

Discord Nitro accounts can upload GIFs as avatars, so the image
mimetype checker code should check for the GIF magic number too.

Signed-off-by: SunDwarf <[email protected]>
pull/447/head
SunDwarf 8 years ago
parent
commit
e7c5ef181f
No known key found for this signature in database GPG Key ID: FE8BF5540067257C
  1. 2
      discord/utils.py

2
discord/utils.py

@ -246,6 +246,8 @@ def _get_mime_type_for_image(data):
return 'image/png'
elif data.startswith(b'\xFF\xD8') and data.endswith(b'\xFF\xD9'):
return 'image/jpeg'
elif data.startswith(b'\x47\x49\x46\x38\x37\x61') or data.startswith(b'\x47\x49\x46\x38\x39\x61'):
return 'image/gif'
else:
raise InvalidArgument('Unsupported image type given')

Loading…
Cancel
Save