]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #22028: Ensure mimetypes will not open registry keys with embedded nulls
authorSteve Dower <steve.dower@microsoft.com>
Tue, 10 Mar 2015 20:19:17 +0000 (13:19 -0700)
committerSteve Dower <steve.dower@microsoft.com>
Tue, 10 Mar 2015 20:19:17 +0000 (13:19 -0700)
Lib/mimetypes.py

index ec8fd995ee97511a3e77ba968dfd6ce4ede21a5d..a39b543c4c9ac08dc2eedc039bf0415ebc18f40f 100644 (file)
@@ -242,9 +242,12 @@ class MimeTypes:
             i = 0
             while True:
                 try:
-                    yield _winreg.EnumKey(mimedb, i)
+                    ctype = _winreg.EnumKey(mimedb, i)
                 except EnvironmentError:
                     break
+                else:
+                    if '\0' not in ctype:
+                        yield ctype
                 i += 1
 
         default_encoding = sys.getdefaultencoding()