Allow absolute paths when not restricting to workspace root (#4946)

* restrict_to_root fix

* Fix formatting

---------

Co-authored-by: Reinier van der Leer <github@pwuts.nl>
This commit is contained in:
Antonov Maxim
2023-07-13 20:21:25 +03:00
committed by GitHub
parent a0f5aa942d
commit ed12b2c7d6

View File

@@ -123,7 +123,11 @@ class Workspace:
logger.debug(f"Resolved root as '{root}'")
# Allow exception for absolute paths if they are contained in your workspace directory.
if relative_path.is_absolute() and not relative_path.is_relative_to(root):
if (
relative_path.is_absolute()
and restrict_to_root
and not relative_path.is_relative_to(root)
):
raise ValueError(
f"Attempted to access absolute path '{relative_path}' in workspace '{root}'."
)