Skip to content

Commit 007cf56

Browse files
Merge pull request #17 from mariobuikhuizen/fix_symlink_content
fix: 404 error on retrieving snippet content in symlinked dir
2 parents 03bbaea + 2cfb179 commit 007cf56

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

jupyterlab-snippets/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version_info = (0, 3, 1)
1+
version_info = (0, 3, 2)
22
__version__ = ".".join(map(str, version_info))

jupyterlab-snippets/loader.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ def get_snippet_content(self, snippet):
3030
path = os.path.join(root_path, *snippet)
3131

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

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

43+
print(f'jupyterlab-snippets: {snippet} not found in {self.snippet_paths}')
4144
raise tornado.web.HTTPError(status_code=404)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jupyterlab-snippets",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "Snippets Extension for JupyterLab",
55
"keywords": [
66
"jupyter",

0 commit comments

Comments
 (0)