gh-128703: Fix mimetypes.guess_type for empty Content-Type in registry (GH-128854)

This commit is contained in:
RUANG (James Roy) 2025-02-15 01:26:26 +08:00 committed by GitHub
parent 3402e133ef
commit 303043f506
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -90,6 +90,8 @@ class MimeTypes:
list of standard types, else to the list of non-standard list of standard types, else to the list of non-standard
types. types.
""" """
if not type:
return
self.types_map[strict][ext] = type self.types_map[strict][ext] = type
exts = self.types_map_inv[strict].setdefault(type, []) exts = self.types_map_inv[strict].setdefault(type, [])
if ext not in exts: if ext not in exts:

View file

@ -0,0 +1,2 @@
Fix :func:`mimetypes.guess_type` to use default mapping for empty
``Content-Type`` in registry.