]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-128703: Fix mimetypes.guess_type for empty Content-Type in registry (GH-128854)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 17 Feb 2025 15:36:49 +0000 (16:36 +0100)
committerGitHub <noreply@github.com>
Mon, 17 Feb 2025 15:36:49 +0000 (15:36 +0000)
(cherry picked from commit 303043f5062c1e7ffb7907abde61dbf13c98f8e9)

Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com>
Lib/mimetypes.py
Misc/NEWS.d/next/Library/2025-01-15-12-04-30.gh-issue-128703.6WPf38.rst [new file with mode: 0644]

index 8604000ed77a196af6da0d77c7e614588d2dad9e..2af7c4b7b80822238ec3a860b154a7255cedd6d1 100644 (file)
@@ -95,6 +95,8 @@ class MimeTypes:
         list of standard types, else to the list of non-standard
         types.
         """
+        if not type:
+            return
         self.types_map[strict][ext] = type
         exts = self.types_map_inv[strict].setdefault(type, [])
         if ext not in exts:
diff --git a/Misc/NEWS.d/next/Library/2025-01-15-12-04-30.gh-issue-128703.6WPf38.rst b/Misc/NEWS.d/next/Library/2025-01-15-12-04-30.gh-issue-128703.6WPf38.rst
new file mode 100644 (file)
index 0000000..1e6af90
--- /dev/null
@@ -0,0 +1,2 @@
+Fix :func:`mimetypes.guess_type` to use default mapping for empty
+``Content-Type`` in registry.