Skip to content

Commit d78e113

Browse files
gh-128703: Fix mimetypes.guess_type for empty Content-Type in registry (GH-128854)
(cherry picked from commit 303043f) Co-authored-by: RUANG (James Roy) <[email protected]>
1 parent 320316e commit d78e113

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Lib/mimetypes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def add_type(self, type, ext, strict=True):
9595
list of standard types, else to the list of non-standard
9696
types.
9797
"""
98+
if not type:
99+
return
98100
self.types_map[strict][ext] = type
99101
exts = self.types_map_inv[strict].setdefault(type, [])
100102
if ext not in exts:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix :func:`mimetypes.guess_type` to use default mapping for empty
2+
``Content-Type`` in registry.

0 commit comments

Comments
 (0)