8000 gh-129965: Add missing MIME types (#129969) · python/cpython@1cf9b6d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1cf9b6d

Browse files
hugovkencukou
andauthored
gh-129965: Add missing MIME types (#129969)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent d0a1e5c commit 1cf9b6d

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,25 @@ mimetypes
614614

615615
(Contributed by Hugo van Kemenade in :gh:`85957`.)
616616

617+
* More MIME type changes:
618+
619+
* :rfc:`2361`: Change type for ``.avi`` to ``video/vnd.avi``
620+
and for ``.wav`` to ``audio/vnd.wave``
621+
* :rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``))
622+
* :rfc:`5334`: Add Ogg media (``.oga``, ``.ogg`` and ``.ogx``)
623+
* :rfc:`9639`: Add FLAC ``audio/flac`` (``.flac``)
624+
* De facto: Add WebM ``audio/webm`` (``.weba``)
625+
* `ECMA-376
626+
<https://ecma-international.org/publications-and-standards/standards/ecma-376/>`__:
627+
Add ``.docx``, ``.pptx`` and ``.xlsx`` types
628+
* `OASIS
629+
<https://docs.oasis-open.org/office/v1.2/cs01/OpenDocument-v1.2-cs01-part1.html#Appendix_C>`__:
630+
Add OpenDocument ``.odg``, ``.odp``, ``.ods`` and ``.odt`` types
631+
* `W3C <https://www.w3.org/TR/epub-33/#app-media-type>`__:
632+
Add EPUB ``application/epub+zip`` (``.epub``)
633+
634+
(Contributed by Hugo van Kemenade in :gh:`129965`.)
635+
617636

618637
multiprocessing
619638
---------------

Lib/mimetypes.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ def _default_mime_types():
465465
types_map = _types_map_default = {
466466
'.js' : 'text/javascript',
467467
'.mjs' : 'text/javascript',
468+
'.epub' : 'application/epub+zip',
468469
'.json' : 'application/json',
469470
'.webmanifest': 'application/manifest+json',
470471
'.doc' : 'application/msword',
@@ -480,6 +481,7 @@ def _default_mime_types():
480481
'.obj' : 'application/octet-stream',
481482
'.so' : 'application/octet-stream',
482483
'.oda' : 'application/oda',
484+
'.ogx' : 'application/ogg',
483485
'.pdf' : 'application/pdf',
484486
'.p7c' : 'application/pkcs7-mime',
485487
'.ps' : 'application/postscript',
@@ -496,6 +498,13 @@ def _default_mime_types():
496498
'.ppa' : 'application/vnd.ms-powerpoint',
497499
'.pps' : 'application/vnd.ms-powerpoint',
498500
'.pwz' : 'application/vnd.ms-powerpoint',
501+
'.odg' : 'application/vnd.oasis.opendocument.graphics',
502+
'.odp' : 'application/vnd.oasis.opendocument.presentation',
503+
'.ods' : 'application/vnd.oasis.opendocument.spreadsheet',
504+
'.odt' : 'application/vnd.oasis.opendocument.text',
505+
'.pptx' : 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
506+
'.xlsx' : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
507+
'.docx' : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
499508
'.wasm' : 'application/wasm',
500509
'.bcpio' : 'application/x-bcpio',
501510
'.cpio' : 'application/x-cpio',
@@ -546,17 +555,21 @@ def _default_mime_types():
546555
'.ass' : 'audio/aac',
547556
'.au' : 'audio/basic',
548557
'.snd' : 'audio/basic',
558+
'.flac' : 'audio/flac',
549559
'.mka' : 'audio/matroska',
560+
'.m4a' : 'audio/mp4',
550561
'.mp3' : 'audio/mpeg',
551562
'.mp2' : 'audio/mpeg',
563+
'.ogg' : 'audio/ogg',
552564
'.opus' : 'audio/opus',
553565
'.aif' : 'audio/x-aiff',
554566
'.aifc' : 'audio/x-aiff',
555567
'.aiff' : 'audio/x-aiff',
556568
'.ra' : 'audio/x-pn-realaudio',
557-
'.wav' : 'audio/x-wav',
569+
'.wav' : 'audio/vnd.wave',
558570
'.otf' : 'font/otf',
559571
'.ttf' : 'font/ttf',
572+
'.weba' : 'audio/webm',
560573
'.woff' : 'font/woff',
561574
'.woff2' : 'font/woff2',
562575
'.avif' : 'image/avif',
@@ -629,10 +642,11 @@ def _default_mime_types():
629642
'.mpa' : 'video/mpeg',
630643
'.mpe' : 'video/mpeg',
631644
'.mpg' : 'video/mpeg',
645+
'.ogv' : 'video/ogg',
632646
'.mov' : 'video/quicktime',
633647
'.qt' : 'video/quicktime',
634648
'.webm' : 'video/webm',
635-
'.avi' : 'video/x-msvideo',
649+
'.avi' : 'video/vnd.avi',
636650
'.movie' : 'video/x-sgi-movie',
637651
}
638652

Lib/test/test_mimetypes.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,31 @@ def test_guess_known_extensions(self):
224224
def test_preferred_extension(self):
225225
def check_extensions():
226226
for mime_type, ext in (
227+
("application/epub+zip", ".epub"),
227228
("application/octet-stream", ".bin"),
229+
("application/ogg", ".ogx"),
228230
("application/postscript", ".ps"),
229231
("application/vnd.apple.mpegurl", ".m3u"),
230232
("application/vnd.ms-excel", ".xls"),
231233
("application/vnd.ms-fontobject", ".eot"),
232234
("application/vnd.ms-powerpoint", ".ppt"),
235+
("application/vnd.oasis.opendocument.graphics", ".odg"),
236+
("application/vnd.oasis.opendocument.presentation", ".odp"),
237+
("application/vnd.oasis.opendocument.spreadsheet", ".ods"),
238+
("application/vnd.oasis.opendocument.text", ".odt"),
239+
("application/vnd.openxmlformats-officedocument.presentationml.presentation", ".pptx"),
240+
("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".xlsx"),
241+
("application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".docx"),
233242
("application/x-texinfo", ".texi"),
234243
("application/x-troff", ".roff"),
235244
("application/xml", ".xsl"),
245+
("audio/flac", ".flac"),
236246
("audio/matroska", ".mka"),
247+
("audio/mp4", ".m4a"),
237248
("audio/mpeg", ".mp3"),
249+
("audio/ogg", ".ogg"),
250+
("audio/vnd.wave", ".wav"),
251+
("audio/webm", ".weba"),
238252
("font/otf", ".otf"),
239253
("font/ttf", ".ttf"),
240254
("font/woff", ".woff"),
@@ -244,13 +258,13 @@ def check_extensions():
244258
("image/fits", ".fits"),
245259
("image/g3fax", ".g3"),
246260
("image/jp2", ".jp2"),
261+
("image/jpeg", ".jpg"),
247262
("image/jpm", ".jpm"),
248263
("image/t38", ".t38"),
249-
("image/webp", ".webp"),
250-
("image/wmf", ".wmf"),
251-
("image/jpeg", ".jpg"),
252264
("image/tiff", ".tiff"),
253265
("image/tiff-fx", ".tfx"),
266+
("image/webp", ".webp"),
267+
("image/wmf", ".wmf"),
254268
("message/rfc822", ".eml"),
255269
("text/html", ".html"),
256270
("text/plain", ".txt"),
@@ -259,7 +273,9 @@ def check_extensions():
259273
("video/matroska", ".mkv"),
260274
("video/matroska-3d", ".mk3d"),
261275
("video/mpeg", ".mpeg"),
276+
("video/ogg", ".ogv"),
262277
("video/quicktime", ".mov"),
278+
("video/vnd.avi", ".avi"),
263279
):
264280
with self.subTest(mime_type=mime_type, ext=ext):
265281
self.assertEqual(mimetypes.guess_extension(mime_type), ext)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Update MIME types for ``.avi`` and ``.wav``. Add MIME types for ``.docx``,
2+
``.pptx``, ``.xlsx``, ``.epub``, ``.flac``, ``.m4a``, ``.odg``, ``.odp``,
3+
``.ods``, ``.odt``, ``.oga``, ``.ogg``, ``.ogx`` and ``.weba``. Patch by
4+
Hugo van Kemenade.

0 commit comments

Comments
 (0)
0