Skip to content

Commit 8c8ce33

Browse files
authored
Merge pull request #4528 from minrk/override-mime-types
explicitly ignore windows registry for mimetypes
2 parents 55e7a66 + 2fabe50 commit 8c8ce33

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
@@ -1623,11 +1623,16 @@ def init_server_extensions(self):
16231623
exc_info=True)
16241624

16251625
def init_mime_overrides(self):
1626-
# On some Windows machines, an application has registered an incorrect
1627-
# mimetype for CSS and JavaScript in the registry.
1626+
# On some Windows machines, an application has registered incorrect
1627+
# mimetypes in the registry.
16281628
# Tornado uses this when serving .css and .js files, causing browsers to
16291629
# reject these files. We know the mimetype always needs to be text/css for css
1630-
# and application/javascript for JS, so we override it here.
1630+
# and application/javascript for JS, so we override it here
1631+
# and explicitly tell the mimetypes to not trust the Windows registry
1632+
if os.name == 'nt':
1633+
# do not trust windows registry, which regularly has bad info
1634+
mimetypes.init(files=[])
1635+
# ensure css, js are correct, which are required for pages to function
16311636
mimetypes.add_type('text/css', '.css')
16321637
mimetypes.add_type('application/javascript', '.js')
16331638

0 commit comments

Comments
 (0)