Skip to content
Open
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
14 changes: 14 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,20 @@ mimetypes
* Add ``application/toml``. (Contributed by Gil Forcada in :gh:`139959`.)
* Rename ``application/x-texinfo`` to ``application/texinfo``.
(Contributed by Charlie Lin in :gh:`140165`)
* Add the following:
- ``application/efi``
- ``application/pem-certificate-chain``
- ``application/pgp-keys``
- ``application/sql``
- ``application/zstd``
- ``application/ocsp-request``
- ``application/ocsp-response``
- ``application/mathematica``
- ``application/mathml+xml``
- ``application/mbox``
- ``application/pem-certificate-chain``

(Contributed by Charlie Lin in :gh:`140393`)


pathlib
Expand Down
13 changes: 13 additions & 0 deletions Lib/mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,16 @@ def _default_mime_types():
types_map = _types_map_default = {
'.js' : 'text/javascript',
'.mjs' : 'text/javascript',
'.efi' : 'application/efi',
'.epub' : 'application/epub+zip',
'.gz' : 'application/gzip',
'.json' : 'application/json',
'.webmanifest': 'application/manifest+json',
'.nb' : 'application/mathematica',
'.ma' : 'application/mathematica',
'.mb' : 'application/mathematica',
'.mml' : 'application/mathml+xml',
'.mbox' : 'application/mbox',
'.doc' : 'application/msword',
'.dot' : 'application/msword',
'.wiz' : 'application/msword',
Expand All @@ -493,13 +499,19 @@ def _default_mime_types():
'.o' : 'application/octet-stream',
'.obj' : 'application/octet-stream',
'.so' : 'application/octet-stream',
'.ors' : 'application/ocsp-response',
'.orq' : 'application/ocsp-request',
'.oda' : 'application/oda',
'.ogx' : 'application/ogg',
'.pdf' : 'application/pdf',
'.pem' : 'application/pem-certificate-chain',
'.asc' : 'application/pgp-keys',
'.p7c' : 'application/pkcs7-mime',
'.ps' : 'application/postscript',
'.ai' : 'application/postscript',
'.eps' : 'application/postscript',
'.rfcxml' : 'application/rfc+xml',
'.sql' : 'application/sql',
'.texi' : 'application/texinfo',
'.texinfo': 'application/texinfo',
'.toml' : 'application/toml',
Expand Down Expand Up @@ -566,6 +578,7 @@ def _default_mime_types():
'.yaml' : 'application/yaml',
'.yml' : 'application/yaml',
'.zip' : 'application/zip',
'.zst' : 'application/zstd',
'.3gp' : 'audio/3gpp',
'.3gpp' : 'audio/3gpp',
'.3g2' : 'audio/3gpp2',
Expand Down
13 changes: 13 additions & 0 deletions Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,23 @@ def test_guess_known_extensions(self):
def test_preferred_extension(self):
def check_extensions():
for mime_type, ext in (
('applicaion/efi', '.efi'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we (and especially me!) have been adding new MIME types to this test, but I'm now thinking there's not much point, we're essentially duplicating types_map in reverse.

It's useful to have some in here, to test the lookup works, but we don't really need all.

When we have multiple extensions (for example, application/mathematica has .ma, .mb and .na), maybe it's useful to include the test to show which extension it returns.

I'm not suggesting removing all existing ones, but shall we remove the new ones here, other than for application/mathematica?

("application/epub+zip", ".epub"),
('application/json', '.json'),
('application/manifest+json', '.webmanifest'),
('application/mathematica', '.nb'),
('application/mathml+xml', '.mml'),
('application/mbox', '.mbox'),
("application/octet-stream", ".bin"),
("application/gzip", ".gz"),
('application/ocsp-response', '.ors'),
('application/ocsp-request', '.orq'),
('application/pem-certificate-chain', '.pem'),
('application/pgp-keys', '.asc'),
("application/ogg", ".ogx"),
("application/postscript", ".ps"),
('application/rfc+xml', '.rfcxml'),
('application/sql', '.sql'),
("application/texinfo", ".texi"),
("application/toml", ".toml"),
("application/vnd.apple.mpegurl", ".m3u"),
Expand All @@ -251,6 +263,7 @@ def check_extensions():
("application/x-troff", ".roff"),
("application/xml", ".xsl"),
("application/yaml", ".yaml"),
('application/zstd', '.zst'),
("audio/flac", ".flac"),
("audio/matroska", ".mka"),
("audio/mp4", ".m4a"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:mod:`mimetypes`: Add the following MIME types:

- ``application/efi``
- ``application/mathematica``
- ``application/mathml+xml``
- ``application/mbox``
- ``application/ocsp-request``
- ``application/ocsp-response``
- ``application/pem-certificate-chain``
- ``application/pgp-keys``
- ``application/sql``
- ``application/zstd``
Loading