Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make 'cwd' param for TerminalManager absolute #749

Merged
merged 1 commit into from Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions jupyter_server/terminal/api_handlers.py
@@ -1,4 +1,5 @@
import json
import os

from tornado import web

Expand Down Expand Up @@ -26,6 +27,15 @@ def post(self):
"""POST /terminals creates a new terminal and redirects to it"""
data = self.get_json_body() or {}

# if cwd is a relative path, it should be relative to the root_dir,
# but if we pass it as relative, it will we be considered as relative to
# the path jupyter_server was started in
if "cwd" in data.keys():
if not os.path.isabs(data["cwd"]):
cwd = data["cwd"]
cwd = os.path.join(self.settings["server_root_dir"], cwd)
data["cwd"] = cwd

model = self.terminal_manager.create(**data)
self.finish(json.dumps(model))

Expand Down