mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Merge pull request #5158 from ivanov/fix-5157
log refusal to serve hidden directories
This commit is contained in:
commit
8d38e042df
@ -263,6 +263,7 @@ class AuthenticatedFileHandler(IPythonHandler, web.StaticFileHandler):
|
||||
abs_path = super(AuthenticatedFileHandler, self).validate_absolute_path(root, absolute_path)
|
||||
abs_root = os.path.abspath(root)
|
||||
if is_hidden(abs_path, abs_root):
|
||||
self.log.info("Refusing to serve hidden file, via 404 Error")
|
||||
raise web.HTTPError(404)
|
||||
return abs_path
|
||||
|
||||
|
@ -180,7 +180,10 @@ class FileNotebookManager(NotebookManager):
|
||||
"""List the directories for a given API style path."""
|
||||
path = path.strip('/')
|
||||
os_path = self._get_os_path('', path)
|
||||
if not os.path.isdir(os_path) or is_hidden(os_path, self.notebook_dir):
|
||||
if not os.path.isdir(os_path):
|
||||
raise web.HTTPError(404, u'directory does not exist: %r' % os_path)
|
||||
elif is_hidden(os_path, self.notebook_dir):
|
||||
self.log.info("Refusing to serve hidden directory, via 404 Error")
|
||||
raise web.HTTPError(404, u'directory does not exist: %r' % os_path)
|
||||
dir_names = os.listdir(os_path)
|
||||
dirs = []
|
||||
|
@ -62,9 +62,12 @@ class TreeHandler(IPythonHandler):
|
||||
self.log.debug("Redirecting %s to %s", self.request.path, url)
|
||||
self.redirect(url)
|
||||
else:
|
||||
if not nbm.path_exists(path=path) or nbm.is_hidden(path):
|
||||
if not nbm.path_exists(path=path):
|
||||
# Directory is hidden or does not exist.
|
||||
raise web.HTTPError(404)
|
||||
elif nbm.is_hidden(path):
|
||||
self.log.info("Refusing to serve hidden directory, via 404 Error")
|
||||
raise web.HTTPError(404)
|
||||
breadcrumbs = self.generate_breadcrumbs(path)
|
||||
page_title = self.generate_page_title(path)
|
||||
self.write(self.render_template('tree.html',
|
||||
|
Loading…
Reference in New Issue
Block a user