]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-128703: Fix mimetypes.guess_type for empty Content-Type in registry (GH-128854)
authorRUANG (James Roy) <longjinyii@outlook.com>
Fri, 14 Feb 2025 17:26:26 +0000 (01:26 +0800)
committerGitHub <noreply@github.com>
Fri, 14 Feb 2025 17:26:26 +0000 (17:26 +0000)
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 753238354f6d366d7b8d81976b6e582608c9c4e4..3e1c3cf25d8405b936abee3e4763f9130f35e05c 100644 (file)
@@ -90,6 +90,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.