Skip to content

Commit 2fabe50

Browse files
committed
explicitly ignore windows registry for mimetypes
since it has proven untrustworthy for many users
1 parent b981c5b commit 2fabe50

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

notebook/notebookapp.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,11 +1618,16 @@ def init_server_extensions(self):
16181618
exc_info=True)
16191619

16201620
def init_mime_overrides(self):
1621-
# On some Windows machines, an application has registered an incorrect
1622-
# mimetype for CSS and JavaScript in the registry.
1621+
# On some Windows machines, an application has registered incorrect
1622+
# mimetypes in the registry.
16231623
# Tornado uses this when serving .css and .js files, causing browsers to
16241624
# reject these files. We know the mimetype always needs to be text/css for css
1625-
# and application/javascript for JS, so we override it here.
1625+
# and application/javascript for JS, so we override it here
1626+
# and explicitly tell the mimetypes to not trust the Windows registry
1627+
if os.name == 'nt':
1628+
# do not trust windows registry, which regularly has bad info
1629+
mimetypes.init(files=[])
1630+
# ensure css, js are correct, which are required for pages to function
16261631
mimetypes.add_type('text/css', '.css')
16271632
mimetypes.add_type('application/javascript', '.js')
16281633

0 commit comments

Comments
 (0)