Fix fro symlink failures

Issue outlined in https://github.com/yeicor-3d/yet-another-cad-viewer/issues/258
This commit is contained in:
Mac Ryan
2025-09-26 14:44:24 +02:00
committed by GitHub
parent 37ddf9ab63
commit fc737583fd

View File

@@ -42,8 +42,8 @@ class HTTPHandler(SimpleHTTPRequestHandler):
path = super().translate_path(path) path = super().translate_path(path)
path = os.path.realpath(path) # Avoid symlink hacks path = os.path.realpath(path) # Avoid symlink hacks
if self.directory: # Ensure proper subdirectory if self.directory: # Ensure proper subdirectory
base = os.path.abspath(self.directory) base = os.path.realpath(self.directory)
if not os.path.abspath(path).startswith(base): if not path.startswith(base):
self.send_error(HTTPStatus.FORBIDDEN, "Path is not in the frontend directory") self.send_error(HTTPStatus.FORBIDDEN, "Path is not in the frontend directory")
return '' return ''
return path return path