8000 gh-75223: Reject undotted extensions in mimetypes.add_type by OddBloke · Pull Request #2895 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-75223: Reject undotted extensions in mimetypes.add_type #2895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Next Next commit
Add a test for mimetypes.add_type
  • Loading branch information
OddBloke committed Sep 10, 2019
commit 2e6a0e5714cc6893ef427f6e9001b4174d607a8c
7 changes: 7 additions & 0 deletions Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ def test_keywords_args_api(self):
self.assertEqual(self.db.guess_extension(
type='image/jpg', strict=False), '.jpg')

def test_added_types_are_used(self):
mime_type, _ = mimetypes.guess_type('test.myext')
self.assertEqual(None, mime_type)
mimetypes.add_type('testing/type', '.myext')
mime_type, _ = mimetypes.guess_type('test.myext')
self.assertEqual('testing/type', mime_type)


@unittest.skipUnless(sys.platform.startswith("win"), "Windows only")
class Win32MimeTypesTestCase(unittest.TestCase):
Expand Down
0