mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-141018: Update .exe, .dll, .rtf and .jpg mime types in mimetypes (#141023)
This commit is contained in:
parent
7800b78067
commit
31ea3f3c76
3 changed files with 15 additions and 19 deletions
|
|
@ -489,8 +489,6 @@ def _default_mime_types():
|
|||
'.cjs' : 'application/node',
|
||||
'.bin' : 'application/octet-stream',
|
||||
'.a' : 'application/octet-stream',
|
||||
'.dll' : 'application/octet-stream',
|
||||
'.exe' : 'application/octet-stream',
|
||||
'.o' : 'application/octet-stream',
|
||||
'.obj' : 'application/octet-stream',
|
||||
'.so' : 'application/octet-stream',
|
||||
|
|
@ -501,12 +499,15 @@ def _default_mime_types():
|
|||
'.p7c' : 'application/pkcs7-mime',
|
||||
'.ps' : 'application/postscript',
|
||||
'.eps' : 'application/postscript',
|
||||
'.rtf' : 'application/rtf',
|
||||
'.texi' : 'application/texinfo',
|
||||
'.texinfo': 'application/texinfo',
|
||||
'.toml' : 'application/toml',
|
||||
'.trig' : 'application/trig',
|
||||
'.m3u' : 'application/vnd.apple.mpegurl',
|
||||
'.m3u8' : 'application/vnd.apple.mpegurl',
|
||||
'.dll' : 'application/vnd.microsoft.portable-executable',
|
||||
'.exe' : 'application/vnd.microsoft.portable-executable',
|
||||
'.xls' : 'application/vnd.ms-excel',
|
||||
'.xlb' : 'application/vnd.ms-excel',
|
||||
'.eot' : 'application/vnd.ms-fontobject',
|
||||
|
|
@ -649,7 +650,6 @@ def _default_mime_types():
|
|||
'.pl' : 'text/plain',
|
||||
'.srt' : 'text/plain',
|
||||
'.rtx' : 'text/richtext',
|
||||
'.rtf' : 'text/rtf',
|
||||
'.tsv' : 'text/tab-separated-values',
|
||||
'.vtt' : 'text/vtt',
|
||||
'.py' : 'text/x-python',
|
||||
|
|
@ -682,11 +682,9 @@ 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',
|
||||
'.pict': 'image/pict',
|
||||
'.pct' : 'image/pict',
|
||||
'.pic' : 'image/pict',
|
||||
|
|
|
|||
|
|
@ -112,13 +112,12 @@ def test_non_standard_types(self):
|
|||
eq = self.assertEqual
|
||||
# First try strict
|
||||
eq(self.db.guess_file_type('foo.xul', strict=True), (None, None))
|
||||
eq(self.db.guess_extension('image/jpg', strict=True), None)
|
||||
# And then non-strict
|
||||
eq(self.db.guess_file_type('foo.xul', strict=False), ('text/xul', None))
|
||||
eq(self.db.guess_file_type('foo.XUL', strict=False), ('text/xul', None))
|
||||
eq(self.db.guess_file_type('foo.invalid', strict=False), (None, None))
|
||||
eq(self.db.guess_extension('image/jpg', strict=False), '.jpg')
|
||||
eq(self.db.guess_extension('image/JPG', strict=False), '.jpg')
|
||||
eq(self.db.guess_extension('image/jpeg', strict=False), '.jpg')
|
||||
eq(self.db.guess_extension('image/JPEG', strict=False), '.jpg')
|
||||
|
||||
def test_filename_with_url_delimiters(self):
|
||||
# bpo-38449: URL delimiters cases should be handled also.
|
||||
|
|
@ -179,8 +178,8 @@ def test_guess_all_types(self):
|
|||
self.assertTrue(set(all) >= {'.bat', '.c', '.h', '.ksh', '.pl', '.txt'})
|
||||
self.assertEqual(len(set(all)), len(all)) # no duplicates
|
||||
# And now non-strict
|
||||
all = self.db.guess_all_extensions('image/jpg', strict=False)
|
||||
self.assertEqual(all, ['.jpg'])
|
||||
all = self.db.guess_all_extensions('image/jpeg', strict=False)
|
||||
self.assertEqual(all, ['.jpg', '.jpe', '.jpeg'])
|
||||
# And now for no hits
|
||||
all = self.db.guess_all_extensions('image/jpg', strict=True)
|
||||
self.assertEqual(all, [])
|
||||
|
|
@ -231,6 +230,7 @@ def check_extensions():
|
|||
("application/ogg", ".ogx"),
|
||||
("application/pdf", ".pdf"),
|
||||
("application/postscript", ".ps"),
|
||||
("application/rtf", ".rtf"),
|
||||
("application/texinfo", ".texi"),
|
||||
("application/toml", ".toml"),
|
||||
("application/vnd.apple.mpegurl", ".m3u"),
|
||||
|
|
@ -281,7 +281,6 @@ def check_extensions():
|
|||
("model/stl", ".stl"),
|
||||
("text/html", ".html"),
|
||||
("text/plain", ".txt"),
|
||||
("text/rtf", ".rtf"),
|
||||
("text/x-rst", ".rst"),
|
||||
("video/matroska", ".mkv"),
|
||||
("video/matroska-3d", ".mk3d"),
|
||||
|
|
@ -372,9 +371,7 @@ def test_keywords_args_api(self):
|
|||
self.assertEqual(self.db.guess_type(
|
||||
url="scheme:foo.html", strict=True), ("text/html", None))
|
||||
self.assertEqual(self.db.guess_all_extensions(
|
||||
type='image/jpg', strict=True), [])
|
||||
self.assertEqual(self.db.guess_extension(
|
||||
type='image/jpg', strict=False), '.jpg')
|
||||
type='image/jpeg', strict=True), ['.jpg', '.jpe', '.jpeg'])
|
||||
|
||||
def test_added_types_are_used(self):
|
||||
mimetypes.add_type('testing/default-type', '')
|
||||
|
|
@ -452,15 +449,15 @@ def test_parse_args(self):
|
|||
args, help_text = mimetypes._parse_args("--invalid")
|
||||
self.assertTrue(help_text.startswith("usage: "))
|
||||
|
||||
args, _ = mimetypes._parse_args(shlex.split("-l -e image/jpg"))
|
||||
args, _ = mimetypes._parse_args(shlex.split("-l -e image/jpeg"))
|
||||
self.assertTrue(args.extension)
|
||||
self.assertTrue(args.lenient)
|
||||
self.assertEqual(args.type, ["image/jpg"])
|
||||
self.assertEqual(args.type, ["image/jpeg"])
|
||||
|
||||
args, _ = mimetypes._parse_args(shlex.split("-e image/jpg"))
|
||||
args, _ = mimetypes._parse_args(shlex.split("-e image/jpeg"))
|
||||
self.assertTrue(args.extension)
|
||||
self.assertFalse(args.lenient)
|
||||
self.assertEqual(args.type, ["image/jpg"])
|
||||
self.assertEqual(args.type, ["image/jpeg"])
|
||||
|
||||
args, _ = mimetypes._parse_args(shlex.split("-l foo.webp"))
|
||||
self.assertFalse(args.extension)
|
||||
|
|
@ -491,7 +488,6 @@ def test_multiple_inputs_error(self):
|
|||
|
||||
def test_invocation(self):
|
||||
for command, expected in [
|
||||
("-l -e image/jpg", ".jpg"),
|
||||
("-e image/jpeg", ".jpg"),
|
||||
("-l foo.webp", "type: image/webp encoding: None"),
|
||||
]:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
:mod:`mimetypes`: Update ``.exe``, ``.dll``, ``.rtf`` and (when
|
||||
``strict=False``) ``.jpg`` to their correct IANA mime type.
|
||||
Loading…
Add table
Add a link
Reference in a new issue