]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129965: Add missing MIME types (#129969)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Fri, 21 Feb 2025 15:44:53 +0000 (17:44 +0200)
committerGitHub <noreply@github.com>
Fri, 21 Feb 2025 15:44:53 +0000 (15:44 +0000)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Doc/whatsnew/3.14.rst
Lib/mimetypes.py
Lib/test/test_mimetypes.py
Misc/NEWS.d/next/Library/2025-02-10-19-16-48.gh-issue-129965.B6wik0.rst [new file with mode: 0644]

index 514c138c0ed0613fb4f7a1d7e826ee6a8cfb1331..eee9bc865357ee7c7f77f28c87582de3d79e416b 100644 (file)
@@ -614,6 +614,25 @@ mimetypes
 
   (Contributed by Hugo van Kemenade in :gh:`85957`.)
 
+* More MIME type changes:
+
+  * :rfc:`2361`: Change type for ``.avi`` to ``video/vnd.avi``
+    and for ``.wav`` to ``audio/vnd.wave``
+  * :rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``))
+  * :rfc:`5334`: Add Ogg media (``.oga``, ``.ogg`` and ``.ogx``)
+  * :rfc:`9639`: Add FLAC ``audio/flac`` (``.flac``)
+  * De facto: Add WebM ``audio/webm`` (``.weba``)
+  * `ECMA-376
+    <https://ecma-international.org/publications-and-standards/standards/ecma-376/>`__:
+    Add ``.docx``, ``.pptx`` and ``.xlsx`` types
+  * `OASIS
+    <https://docs.oasis-open.org/office/v1.2/cs01/OpenDocument-v1.2-cs01-part1.html#Appendix_C>`__:
+    Add OpenDocument ``.odg``, ``.odp``, ``.ods`` and ``.odt`` types
+  * `W3C <https://www.w3.org/TR/epub-33/#app-media-type>`__:
+    Add EPUB ``application/epub+zip`` (``.epub``)
+
+  (Contributed by Hugo van Kemenade in :gh:`129965`.)
+
 
 multiprocessing
 ---------------
index 3e1c3cf25d8405b936abee3e4763f9130f35e05c..ebad9a9ed273370870e99fe06ae3888a34736714 100644 (file)
@@ -465,6 +465,7 @@ def _default_mime_types():
     types_map = _types_map_default = {
         '.js'     : 'text/javascript',
         '.mjs'    : 'text/javascript',
+        '.epub'   : 'application/epub+zip',
         '.json'   : 'application/json',
         '.webmanifest': 'application/manifest+json',
         '.doc'    : 'application/msword',
@@ -480,6 +481,7 @@ def _default_mime_types():
         '.obj'    : 'application/octet-stream',
         '.so'     : 'application/octet-stream',
         '.oda'    : 'application/oda',
+        '.ogx'    : 'application/ogg',
         '.pdf'    : 'application/pdf',
         '.p7c'    : 'application/pkcs7-mime',
         '.ps'     : 'application/postscript',
@@ -496,6 +498,13 @@ def _default_mime_types():
         '.ppa'    : 'application/vnd.ms-powerpoint',
         '.pps'    : 'application/vnd.ms-powerpoint',
         '.pwz'    : 'application/vnd.ms-powerpoint',
+        '.odg'    : 'application/vnd.oasis.opendocument.graphics',
+        '.odp'    : 'application/vnd.oasis.opendocument.presentation',
+        '.ods'    : 'application/vnd.oasis.opendocument.spreadsheet',
+        '.odt'    : 'application/vnd.oasis.opendocument.text',
+        '.pptx'   : 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+        '.xlsx'   : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+        '.docx'   : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
         '.wasm'   : 'application/wasm',
         '.bcpio'  : 'application/x-bcpio',
         '.cpio'   : 'application/x-cpio',
@@ -546,17 +555,21 @@ def _default_mime_types():
         '.ass'    : 'audio/aac',
         '.au'     : 'audio/basic',
         '.snd'    : 'audio/basic',
+        '.flac'   : 'audio/flac',
         '.mka'    : 'audio/matroska',
+        '.m4a'    : 'audio/mp4',
         '.mp3'    : 'audio/mpeg',
         '.mp2'    : 'audio/mpeg',
+        '.ogg'    : 'audio/ogg',
         '.opus'   : 'audio/opus',
         '.aif'    : 'audio/x-aiff',
         '.aifc'   : 'audio/x-aiff',
         '.aiff'   : 'audio/x-aiff',
         '.ra'     : 'audio/x-pn-realaudio',
-        '.wav'    : 'audio/x-wav',
+        '.wav'    : 'audio/vnd.wave',
         '.otf'    : 'font/otf',
         '.ttf'    : 'font/ttf',
+        '.weba'   : 'audio/webm',
         '.woff'   : 'font/woff',
         '.woff2'  : 'font/woff2',
         '.avif'   : 'image/avif',
@@ -629,10 +642,11 @@ def _default_mime_types():
         '.mpa'    : 'video/mpeg',
         '.mpe'    : 'video/mpeg',
         '.mpg'    : 'video/mpeg',
+        '.ogv'    : 'video/ogg',
         '.mov'    : 'video/quicktime',
         '.qt'     : 'video/quicktime',
         '.webm'   : 'video/webm',
-        '.avi'    : 'video/x-msvideo',
+        '.avi'    : 'video/vnd.avi',
         '.movie'  : 'video/x-sgi-movie',
         }
 
index 0a5b511e75537c353340b9fd4ded3e98b2a14284..bceb5c2fa0eb24ce15d7727af4d6e81b377c1b98 100644 (file)
@@ -224,17 +224,31 @@ class MimeTypesTestCase(unittest.TestCase):
     def test_preferred_extension(self):
         def check_extensions():
             for mime_type, ext in (
+                ("application/epub+zip", ".epub"),
                 ("application/octet-stream", ".bin"),
+                ("application/ogg", ".ogx"),
                 ("application/postscript", ".ps"),
                 ("application/vnd.apple.mpegurl", ".m3u"),
                 ("application/vnd.ms-excel", ".xls"),
                 ("application/vnd.ms-fontobject", ".eot"),
                 ("application/vnd.ms-powerpoint", ".ppt"),
+                ("application/vnd.oasis.opendocument.graphics", ".odg"),
+                ("application/vnd.oasis.opendocument.presentation", ".odp"),
+                ("application/vnd.oasis.opendocument.spreadsheet", ".ods"),
+                ("application/vnd.oasis.opendocument.text", ".odt"),
+                ("application/vnd.openxmlformats-officedocument.presentationml.presentation", ".pptx"),
+                ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".xlsx"),
+                ("application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".docx"),
                 ("application/x-texinfo", ".texi"),
                 ("application/x-troff", ".roff"),
                 ("application/xml", ".xsl"),
+                ("audio/flac", ".flac"),
                 ("audio/matroska", ".mka"),
+                ("audio/mp4", ".m4a"),
                 ("audio/mpeg", ".mp3"),
+                ("audio/ogg", ".ogg"),
+                ("audio/vnd.wave", ".wav"),
+                ("audio/webm", ".weba"),
                 ("font/otf", ".otf"),
                 ("font/ttf", ".ttf"),
                 ("font/woff", ".woff"),
@@ -244,13 +258,13 @@ class MimeTypesTestCase(unittest.TestCase):
                 ("image/fits", ".fits"),
                 ("image/g3fax", ".g3"),
                 ("image/jp2", ".jp2"),
+                ("image/jpeg", ".jpg"),
                 ("image/jpm", ".jpm"),
                 ("image/t38", ".t38"),
-                ("image/webp", ".webp"),
-                ("image/wmf", ".wmf"),
-                ("image/jpeg", ".jpg"),
                 ("image/tiff", ".tiff"),
                 ("image/tiff-fx", ".tfx"),
+                ("image/webp", ".webp"),
+                ("image/wmf", ".wmf"),
                 ("message/rfc822", ".eml"),
                 ("text/html", ".html"),
                 ("text/plain", ".txt"),
@@ -259,7 +273,9 @@ class MimeTypesTestCase(unittest.TestCase):
                 ("video/matroska", ".mkv"),
                 ("video/matroska-3d", ".mk3d"),
                 ("video/mpeg", ".mpeg"),
+                ("video/ogg", ".ogv"),
                 ("video/quicktime", ".mov"),
+                ("video/vnd.avi", ".avi"),
             ):
                 with self.subTest(mime_type=mime_type, ext=ext):
                     self.assertEqual(mimetypes.guess_extension(mime_type), ext)
diff --git a/Misc/NEWS.d/next/Library/2025-02-10-19-16-48.gh-issue-129965.B6wik0.rst b/Misc/NEWS.d/next/Library/2025-02-10-19-16-48.gh-issue-129965.B6wik0.rst
new file mode 100644 (file)
index 0000000..b5347d8
--- /dev/null
@@ -0,0 +1,4 @@
+Update MIME types for ``.avi`` and ``.wav``. Add MIME types for ``.docx``,
+``.pptx``, ``.xlsx``, ``.epub``, ``.flac``, ``.m4a``, ``.odg``, ``.odp``,
+``.ods``, ``.odt``, ``.oga``, ``.ogg``, ``.ogx`` and ``.weba``. Patch by
+Hugo van Kemenade.