Skip to content

fix: 404 error on retrieving snippet content in symlinked dir #17

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jupyterlab-snippets/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (0, 3, 1)
version_info = (0, 3, 2)
__version__ = ".".join(map(str, version_info))
5 changes: 4 additions & 1 deletion jupyterlab-snippets/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ def get_snippet_content(self, snippet):
path = os.path.join(root_path, *snippet)

# Prevent access to the entire file system when the path contains '..'
accessible = os.path.realpath(path).startswith(root_path)
accessible = os.path.abspath(path).startswith(root_path)
if not accessible:
print(f'jupyterlab-snippets: {path} not accessible from {root_path}')

if accessible and os.path.isfile(path):
with open(path) as f:
return f.read()
except:
raise tornado.web.HTTPError(status_code=500)

print(f'jupyterlab-snippets: {snippet} not found in {self.snippet_paths}')
raise tornado.web.HTTPError(status_code=404)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jupyterlab-snippets",
"version": "0.3.1",
"version": "0.3.2",
"description": "Snippets Extension for JupyterLab",
"keywords": [
"jupyter",
Expand Down