Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix .jpg resolving to non-standard image/jpg instead of image/jpeg (#4333)

Swapnil Yadavfc681b87b2e6
diff --git a/python/composio/utils/mimetypes.py b/python/composio/utils/mimetypes.py
index a9dbb46be..a402ad565 100644
--- a/python/composio/utils/mimetypes.py
+++ b/python/composio/utils/mimetypes.py
@@ -160,7 +160,7 @@ _types = {
".jfif-bnl": "image/jpeg",
".jpe": "image/jpeg",
".jpeg": "image/jpeg",
- ".jpg": "image/jpg",
+ ".jpg": "image/jpeg",
".jps": "image/x-jps",
".js": "application/javascript",
".json": "application/json",
diff --git a/python/tests/test_mimetypes.py b/python/tests/test_mimetypes.py
index e08543a7f..7e93099ce 100644
--- a/python/tests/test_mimetypes.py
+++ b/python/tests/test_mimetypes.py
@@ -24,6 +24,8 @@ class TestGuess:
("a.css", "text/css"),
("a.js", "application/javascript"),
("a.png", "image/png"),
+ ("a.jpg", "image/jpeg"),
+ ("a.jpeg", "image/jpeg"),
("a.gif", "image/gif"),
("a.mp4", "video/mp4"),
("a.zip", "application/zip"),
@@ -33,6 +35,16 @@ class TestGuess:
"""A known extension resolves to its MIME type."""
assert guess(filename) == expected
+ def test_jpg_uses_the_standard_mime_type(self) -> None:
+ """``.jpg`` resolves to the IANA-registered ``image/jpeg``, matching
+ its ``.jpeg``/``.jpe`` siblings and ``mimetypes.guess_type`` in the
+ standard library, rather than the non-standard ``image/jpg``. The
+ reverse ``_MIME_TO_EXT`` map still accepts ``image/jpg`` from servers
+ that send it."""
+ assert guess("a.jpg") == "image/jpeg"
+ assert guess("a.jpeg") == "image/jpeg"
+ assert guess("a.jpe") == "image/jpeg"
+
def test_extension_lookup_is_case_insensitive(self) -> None:
"""Suffixes are normalized to lower case, matching the sibling
``get_extension_from_mime_type`` helper and ``mimetypes.guess_type``."""