Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,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/>`__:
Expand Down
12 changes: 12 additions & 0 deletions Lib/mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,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',
Expand Down Expand Up @@ -505,10 +506,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',
Expand All @@ -518,10 +522,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',
Expand Down Expand Up @@ -611,6 +617,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',
Expand Down Expand Up @@ -649,6 +658,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',
}

Expand All @@ -658,6 +669,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',
Expand Down
12 changes: 11 additions & 1 deletion Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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
Expand Down Expand Up @@ -227,6 +226,7 @@ def check_extensions():
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"),
Expand All @@ -240,6 +240,11 @@ def check_extensions():
("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"),
Expand Down Expand Up @@ -268,6 +273,9 @@ def check_extensions():
("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"),
Expand All @@ -278,6 +286,8 @@ def check_extensions():
("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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Loading