diff options
-rw-r--r-- | Doc/whatsnew/3.14.rst | 19 | ||||
-rw-r--r-- | Lib/mimetypes.py | 18 | ||||
-rw-r--r-- | Lib/test/test_mimetypes.py | 22 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2025-02-10-19-16-48.gh-issue-129965.B6wik0.rst | 4 |
4 files changed, 58 insertions, 5 deletions
diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 514c138c0ed..eee9bc86535 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -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 --------------- diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 3e1c3cf25d8..ebad9a9ed27 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -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', } diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 0a5b511e755..bceb5c2fa0e 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -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 index 00000000000..b5347d8f4d1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-02-10-19-16-48.gh-issue-129965.B6wik0.rst @@ -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. |