bpo-35474: Fix mimetypes.guess_all_extensions() potentially mutating list (GH-28286)

* Calling guess_all_extensions() with strict=False potentially
  mutated types_map_inv.
* Mutating the result of guess_all_extensions() mutated types_map_inv.
This commit is contained in:
Serhiy Storchaka 2021-09-11 17:44:44 +03:00 committed by GitHub
parent 5f5b7d0c65
commit 97ea18eced
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 8 deletions

View file

@ -175,7 +175,7 @@ class MimeTypes:
but non-standard types.
"""
type = type.lower()
extensions = self.types_map_inv[True].get(type, [])
extensions = list(self.types_map_inv[True].get(type, []))
if not strict:
for ext in self.types_map_inv[False].get(type, []):
if ext not in extensions: