API media_post bug on .jpg/.jpe extension?

I’m working on a twitter > mastodon bot (tootbot) and having some problem with uploaded medias.

When the image is a small JPEG (not resized by mastodon API) the extension it gets is .jpe
When the JPEG image is large and resized, it gets a .jpg extension.

Is this a know problem/bug ?

My code is on GitHub - cquest/tootbot: python bot to clone tweets to a mastodon account

Do you have a sample image available? What do the following commands say:

file filename
identify filename

Here is one example: Christian Quest 🌍 : "Si on y réfléchit, un cadran solaire est une sort…" - amicale.net

The file in the system/media_attachments/files… is correctly identified as JPEG.
The only problem is when it gets federated… on other instances it is not displayed correctly.

The behavior is not consistent on my 3 instances. On one of them, I’ve seen a .jpeg extension.

I’m not familiar with ruby, but it looks like the extension comes from mastodon/media_attachment.rb at master · tootsuite/mastodon · GitHub

Could it be related with a different MIME types list ?

The paperclip library returns ‘jpe’ as a response to content_type_extension call which Mastodon is using as well.

What happens if you replace those calls like this:

(haven’t checked even for syntax)

(posting the same comment at Use .dotextension to get .jpeg by saper · Pull Request #3404 · tootsuite/mastodon · GitHub)

Could you tell me what version you used to reproduce the bug? I could not reproduce it.