Skip to content

Commit

Permalink
Merge pull request #17 from mariobuikhuizen/fix_symlink_content
Browse files Browse the repository at this point in the history
fix: 404 error on retrieving snippet content in symlinked dir
  • Loading branch information
mariobuikhuizen authored Apr 7, 2020
2 parents 03bbaea + 2cfb179 commit 007cf56
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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

0 comments on commit 007cf56

Please sign in to comment.