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

uppercase-lowecase issues in the path on windows #314

Closed
fejesd opened this issue Jun 18, 2020 · 1 comment
Closed

uppercase-lowecase issues in the path on windows #314

fejesd opened this issue Jun 18, 2020 · 1 comment

Comments

@fejesd
Copy link

fejesd commented Jun 18, 2020

I'm not sure about the reason, but I get the following error when I attempt to open the web page on windows:

2020-06-18 14:41:32,469 [tornado.application.ERROR] Uncaught exception GET /index.html (127.0.0.1)
HTTPServerRequest(protocol='http', host='127.0.0.1:5000', method='GET', uri='/index.html', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "E:\devel\script-server-sandbox\tornado\web.py", line 1703, in _execute
    result = await result
  File "E:\devel\script-server-sandbox\tornado\web.py", line 2581, in get
    self.absolute_path = self.validate_absolute_path(self.root, absolute_path)
  File "src\web\server.py", line 126, in wrapper
    return func(self, *args, **kwargs)
  File "src\web\server.py", line 608, in validate_absolute_path
    relative_path = file_utils.relative_path(absolute_path, root)
  File "src\utils\file_utils.py", line 150, in relative_path
    raise ValueError(path + ' is not subpath of ' + parent_path)
ValueError: e:\devel\script-server-sandbox\web\index.html is not subpath of E:\devel\script-server-sandbox\web
2020-06-18 14:41:32,481 [tornado.access.ERROR] 500 GET /index.html (127.0.0.1) 12.97ms

This code has fixed the issue for me, but maybe it is not the best approach:

--- a/src/utils/file_utils.py
+++ b/src/utils/file_utils.py
@@ -141,6 +141,10 @@ def last_modification(folder_paths):
 def relative_path(path, parent_path):
     path = normalize_path(path)
     parent_path = normalize_path(parent_path)
+
+    if os.name == 'nt':
+        path = path.capitalize()
+        parent_path = parent_path.capitalize()

     if not path.startswith(parent_path):
         raise ValueError(path + ' is not subpath of ' + parent_path)
@bugy
Copy link
Owner

bugy commented Jun 18, 2020

Oops, good catch!
May I ask you to replace == 'nt' check with os_utils.is_win()? The latter is more testable

And open a pull request :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants