]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129965: Add more missing MIME types (#132845)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Mon, 28 Apr 2025 15:30:35 +0000 (18:30 +0300)
committerGitHub <noreply@github.com>
Mon, 28 Apr 2025 15:30:35 +0000 (15:30 +0000)
Doc/whatsnew/3.14.rst
Lib/mimetypes.py
Lib/test/test_mimetypes.py
Misc/NEWS.d/next/Library/2025-04-23-18-35-09.gh-issue-129965.nj7Fx2.rst [new file with mode: 0644]

index 82ef636778183b4826d46072c360b35de2f0dde4..9b28d7b6247309cb137d47573d58551521d0522c 100644 (file)
@@ -1001,9 +1001,22 @@ mimetypes
 
   * :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:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``)
   * :rfc:`5334`: Add Ogg media (``.oga``, ``.ogg`` and ``.ogx``)
+  * :rfc:`6713`: Add gzip ``application/gzip`` (``.gz``)
   * :rfc:`9639`: Add FLAC ``audio/flac`` (``.flac``)
+  * Add 7z ``application/x-7z-compressed`` (``.7z``)
+  * Add Android Package ``application/vnd.android.package-archive`` (``.apk``)
+    when not strict
+  * Add deb ``application/x-debian-package`` (``.deb``)
+  * Add glTF binary ``model/gltf-binary`` (``.glb``)
+  * Add glTF JSON/ASCII ``model/gltf+json`` (``.gltf``)
+  * Add M4V ``video/x-m4v`` (``.m4v``)
+  * Add PHP ``application/x-httpd-php`` (``.php``)
+  * Add RAR ``application/vnd.rar`` (``.rar``)
+  * Add RPM ``application/x-rpm`` (``.rpm``)
+  * Add STL ``model/stl`` (``.stl``)
+  * Add Windows Media Video ``video/x-ms-wmv`` (``.wmv``)
   * De facto: Add WebM ``audio/webm`` (``.weba``)
   * `ECMA-376
     <https://ecma-international.org/publications-and-standards/standards/ecma-376/>`__:
index e93e1d5a03a45491ba02531a2254cfd94803039d..b5a1b8da2638e07f64c14730e5059f209c79ecda 100644 (file)
@@ -478,6 +478,7 @@ def _default_mime_types():
         '.js'     : 'text/javascript',
         '.mjs'    : 'text/javascript',
         '.epub'   : 'application/epub+zip',
+        '.gz'     : 'application/gzip',
         '.json'   : 'application/json',
         '.webmanifest': 'application/manifest+json',
         '.doc'    : 'application/msword',
@@ -517,10 +518,13 @@ def _default_mime_types():
         '.pptx'   : 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
         '.xlsx'   : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
         '.docx'   : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+        '.rar'    : 'application/vnd.rar',
         '.wasm'   : 'application/wasm',
+        '.7z'     : 'application/x-7z-compressed',
         '.bcpio'  : 'application/x-bcpio',
         '.cpio'   : 'application/x-cpio',
         '.csh'    : 'application/x-csh',
+        '.deb'    : 'application/x-debian-package',
         '.dvi'    : 'application/x-dvi',
         '.gtar'   : 'application/x-gtar',
         '.hdf'    : 'application/x-hdf',
@@ -530,10 +534,12 @@ def _default_mime_types():
         '.cdf'    : 'application/x-netcdf',
         '.nc'     : 'application/x-netcdf',
         '.p12'    : 'application/x-pkcs12',
+        '.php'    : 'application/x-httpd-php',
         '.pfx'    : 'application/x-pkcs12',
         '.ram'    : 'application/x-pn-realaudio',
         '.pyc'    : 'application/x-python-code',
         '.pyo'    : 'application/x-python-code',
+        '.rpm'    : 'application/x-rpm',
         '.sh'     : 'application/x-sh',
         '.shar'   : 'application/x-shar',
         '.swf'    : 'application/x-shockwave-flash',
@@ -623,6 +629,9 @@ def _default_mime_types():
         '.mht'    : 'message/rfc822',
         '.mhtml'  : 'message/rfc822',
         '.nws'    : 'message/rfc822',
+        '.gltf'   : 'model/gltf+json',
+        '.glb'    : 'model/gltf-binary',
+        '.stl'    : 'model/stl',
         '.css'    : 'text/css',
         '.csv'    : 'text/csv',
         '.html'   : 'text/html',
@@ -661,6 +670,8 @@ def _default_mime_types():
         '.qt'     : 'video/quicktime',
         '.webm'   : 'video/webm',
         '.avi'    : 'video/vnd.avi',
+        '.m4v'    : 'video/x-m4v',
+        '.wmv'    : 'video/x-ms-wmv',
         '.movie'  : 'video/x-sgi-movie',
         }
 
@@ -670,6 +681,7 @@ def _default_mime_types():
     # Please sort these too
     common_types = _common_types_default = {
         '.rtf' : 'application/rtf',
+        '.apk' : 'application/vnd.android.package-archive',
         '.midi': 'audio/midi',
         '.mid' : 'audio/midi',
         '.jpg' : 'image/jpg',
index b9197069a08a884063fb4334cf0321295debefae..dad5dbde7cd7831ccb1c96cd6ce14b38ee572f2a 100644 (file)
@@ -7,7 +7,6 @@ import unittest.mock
 from platform import win32_edition
 from test import support
 from test.support import os_helper
-from test.support.script_helper import run_python_until_end
 
 try:
     import _winapi
@@ -227,6 +226,7 @@ class MimeTypesTestCase(unittest.TestCase):
             for mime_type, ext in (
                 ("application/epub+zip", ".epub"),
                 ("application/octet-stream", ".bin"),
+                ("application/gzip", ".gz"),
                 ("application/ogg", ".ogx"),
                 ("application/postscript", ".ps"),
                 ("application/vnd.apple.mpegurl", ".m3u"),
@@ -240,6 +240,11 @@ class MimeTypesTestCase(unittest.TestCase):
                 ("application/vnd.openxmlformats-officedocument.presentationml.presentation", ".pptx"),
                 ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".xlsx"),
                 ("application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".docx"),
+                ("application/vnd.rar", ".rar"),
+                ("application/x-7z-compressed", ".7z"),
+                ("application/x-debian-package", ".deb"),
+                ("application/x-httpd-php", ".php"),
+                ("application/x-rpm", ".rpm"),
                 ("application/x-texinfo", ".texi"),
                 ("application/x-troff", ".roff"),
                 ("application/xml", ".xsl"),
@@ -268,6 +273,9 @@ class MimeTypesTestCase(unittest.TestCase):
                 ("image/webp", ".webp"),
                 ("image/wmf", ".wmf"),
                 ("message/rfc822", ".eml"),
+                ("model/gltf+json", ".gltf"),
+                ("model/gltf-binary", ".glb"),
+                ("model/stl", ".stl"),
                 ("text/html", ".html"),
                 ("text/plain", ".txt"),
                 ("text/rtf", ".rtf"),
@@ -278,6 +286,8 @@ class MimeTypesTestCase(unittest.TestCase):
                 ("video/ogg", ".ogv"),
                 ("video/quicktime", ".mov"),
                 ("video/vnd.avi", ".avi"),
+                ("video/x-m4v", ".m4v"),
+                ("video/x-ms-wmv", ".wmv"),
             ):
                 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-04-23-18-35-09.gh-issue-129965.nj7Fx2.rst b/Misc/NEWS.d/next/Library/2025-04-23-18-35-09.gh-issue-129965.nj7Fx2.rst
new file mode 100644 (file)
index 0000000..e693a2c
--- /dev/null
@@ -0,0 +1,3 @@
+Add MIME types for ``.7z``, ``.apk``, ``.deb``, ``.glb``, ``.gltf``,
+``.gz``, ``.m4v``, ``.php``, ``.rar``, ``.rpm``, ``.stl`` and ``.wmv``.
+Patch by Hugo van Kemenade.