mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-15 04:00:34 +08:00
updated error messages to not mention hidden files
This commit is contained in:
parent
cb3dc22f0f
commit
b79702ccdb
@ -437,7 +437,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
|
|||||||
raise web.HTTPError(404, four_o_four)
|
raise web.HTTPError(404, four_o_four)
|
||||||
|
|
||||||
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
|
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
|
||||||
self.log.info("Refusing to serve hidden file or file in hidden directory %r, via 404 Error", os_path)
|
self.log.info("Refusing to serve hidden file or directory %r, via 404 Error", os_path)
|
||||||
raise web.HTTPError(404, four_o_four)
|
raise web.HTTPError(404, four_o_four)
|
||||||
|
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
|
|||||||
def _save_directory(self, os_path, model, path=''):
|
def _save_directory(self, os_path, model, path=''):
|
||||||
"""create a directory"""
|
"""create a directory"""
|
||||||
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
|
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
|
||||||
raise web.HTTPError(400, f'Cannot create hidden directory {os_path!r}')
|
raise web.HTTPError(400, f'Cannot create directory {os_path!r}')
|
||||||
if not os.path.exists(os_path):
|
if not os.path.exists(os_path):
|
||||||
with self.perm_to_403():
|
with self.perm_to_403():
|
||||||
os.mkdir(os_path)
|
os.mkdir(os_path)
|
||||||
@ -480,7 +480,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
|
|||||||
os_path = self._get_os_path(path)
|
os_path = self._get_os_path(path)
|
||||||
|
|
||||||
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
|
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
|
||||||
raise web.HTTPError(400, f'Cannot create hidden file or directory {os_path!r}')
|
raise web.HTTPError(400, f'Cannot create file or directory {os_path!r}')
|
||||||
|
|
||||||
self.log.debug("Saving %s", os_path)
|
self.log.debug("Saving %s", os_path)
|
||||||
|
|
||||||
@ -532,7 +532,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
|
|||||||
raise web.HTTPError(404, four_o_four)
|
raise web.HTTPError(404, four_o_four)
|
||||||
|
|
||||||
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
|
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
|
||||||
raise web.HTTPError(400, f'Cannot delete hidden file or directory {os_path!r}')
|
raise web.HTTPError(400, f'Cannot delete file or directory {os_path!r}')
|
||||||
|
|
||||||
def is_non_empty_dir(os_path):
|
def is_non_empty_dir(os_path):
|
||||||
if os.path.isdir(os_path):
|
if os.path.isdir(os_path):
|
||||||
@ -576,7 +576,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if (is_hidden(old_path, self.root_dir) or is_hidden(new_path, self.root_dir)) and not self.allow_hidden:
|
if (is_hidden(old_path, self.root_dir) or is_hidden(new_path, self.root_dir)) and not self.allow_hidden:
|
||||||
raise web.HTTPError(400, f'Cannot rename hidden file or directory {os_path!r}')
|
raise web.HTTPError(400, f'Cannot rename file or directory {os_path!r}')
|
||||||
|
|
||||||
# Perform path validation prior to converting to os-specific value since this
|
# Perform path validation prior to converting to os-specific value since this
|
||||||
# is still relative to root_dir.
|
# is still relative to root_dir.
|
||||||
|
@ -129,7 +129,7 @@ class ContentsHandler(APIHandler):
|
|||||||
model = self.get_json_body()
|
model = self.get_json_body()
|
||||||
old_path = model.get('path')
|
old_path = model.get('path')
|
||||||
if old_path and (cm.is_hidden(path) or cm.is_hidden(old_path)) and not cm.allow_hidden:
|
if old_path and (cm.is_hidden(path) or cm.is_hidden(old_path)) and not cm.allow_hidden:
|
||||||
raise web.HTTPError(400, f'Cannot rename hidden file or directory {path!r}')
|
raise web.HTTPError(400, f'Cannot rename file or directory {path!r}')
|
||||||
if model is None:
|
if model is None:
|
||||||
raise web.HTTPError(400, 'JSON body missing')
|
raise web.HTTPError(400, 'JSON body missing')
|
||||||
model = yield maybe_future(cm.update(model, path))
|
model = yield maybe_future(cm.update(model, path))
|
||||||
@ -200,7 +200,7 @@ class ContentsHandler(APIHandler):
|
|||||||
model = self.get_json_body()
|
model = self.get_json_body()
|
||||||
copy_from = model.get('copy_from')
|
copy_from = model.get('copy_from')
|
||||||
if copy_from and (cm.is_hidden(path) or cm.is_hidden(copy_from)) and not cm.allow_hidden:
|
if copy_from and (cm.is_hidden(path) or cm.is_hidden(copy_from)) and not cm.allow_hidden:
|
||||||
raise web.HTTPError(400, f'Cannot copy hidden file or directory {path!r}')
|
raise web.HTTPError(400, f'Cannot copy file or directory {path!r}')
|
||||||
|
|
||||||
if model is not None:
|
if model is not None:
|
||||||
copy_from = model.get('copy_from')
|
copy_from = model.get('copy_from')
|
||||||
@ -232,7 +232,7 @@ class ContentsHandler(APIHandler):
|
|||||||
if model.get('copy_from'):
|
if model.get('copy_from'):
|
||||||
raise web.HTTPError(400, "Cannot copy with PUT, only POST")
|
raise web.HTTPError(400, "Cannot copy with PUT, only POST")
|
||||||
if model.get('path') and (cm.is_hidden(path) or cm.is_hidden(model.get('path'))) and not cm.allow_hidden:
|
if model.get('path') and (cm.is_hidden(path) or cm.is_hidden(model.get('path'))) and not cm.allow_hidden:
|
||||||
raise web.HTTPError(400, f'Cannot create hidden file or directory {path!r}')
|
raise web.HTTPError(400, f'Cannot create file or directory {path!r}')
|
||||||
exists = yield maybe_future(self.contents_manager.file_exists(path))
|
exists = yield maybe_future(self.contents_manager.file_exists(path))
|
||||||
if exists:
|
if exists:
|
||||||
yield maybe_future(self._save(model, path))
|
yield maybe_future(self._save(model, path))
|
||||||
@ -248,7 +248,7 @@ class ContentsHandler(APIHandler):
|
|||||||
cm = self.contents_manager
|
cm = self.contents_manager
|
||||||
|
|
||||||
if cm.is_hidden(path) and not cm.allow_hidden:
|
if cm.is_hidden(path) and not cm.allow_hidden:
|
||||||
raise web.HTTPError(400, f'Cannot delete hidden file or directory {path!r}')
|
raise web.HTTPError(400, f'Cannot delete file or directory {path!r}')
|
||||||
|
|
||||||
self.log.warning('delete %s', path)
|
self.log.warning('delete %s', path)
|
||||||
yield maybe_future(cm.delete(path))
|
yield maybe_future(cm.delete(path))
|
||||||
|
Loading…
Reference in New Issue
Block a user