We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ecd5b1f commit 40a95e5Copy full SHA for 40a95e5
jupyter_server/services/contents/fileio.py
@@ -270,6 +270,17 @@ def _get_os_path(self, path):
270
if os.path.splitdrive(path)[0]:
271
raise HTTPError(404, "%s is not a relative API path" % path)
272
os_path = to_os_path(ApiPath(path), root)
273
+ # validate os path
274
+ # e.g. "foo\0" raises ValueError: embedded null byte
275
+ try:
276
+ os.lstat(os_path)
277
+ except OSError:
278
+ # OSError could be FileNotFound, PermissionError, etc.
279
+ # those should raise (or not) elsewhere
280
+ pass
281
+ except ValueError:
282
+ raise HTTPError(404, f"{path} is not a valid path") from None
283
+
284
if not (os.path.abspath(os_path) + os.path.sep).startswith(root):
285
raise HTTPError(404, "%s is outside root contents directory" % path)
286
return os_path
0 commit comments