gh-129965: Add missing MIME types (#129969)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
This commit is contained in:
Hugo van Kemenade 2025-02-21 17:44:53 +02:00 committed by GitHub
parent d0a1e5c222
commit 1cf9b6d9b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 58 additions and 5 deletions

View 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
---------------

View 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',
}

View 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)

View file

@ -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.