From: Steve Dower Date: Tue, 10 Mar 2015 20:19:17 +0000 (-0700) Subject: Issue #22028: Ensure mimetypes will not open registry keys with embedded nulls X-Git-Tag: v2.7.10rc1~135 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=32608c1b10f4646c9c3dda5110d52472cca86233;p=thirdparty%2FPython%2Fcpython.git Issue #22028: Ensure mimetypes will not open registry keys with embedded nulls --- diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index ec8fd995ee97..a39b543c4c9a 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -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()