Fix resolve_path allowing paths outside its folder

This happened if the directory name was a prefix of the offending file name.
This commit is contained in:
I-Al-Istannen 2020-04-20 16:07:14 +02:00
parent 63bbcad918
commit 135a8dce4b

View File

@ -67,7 +67,7 @@ def resolve_path(directory: Path, target_file: Path) -> Path:
"""
absolute_path = directory.joinpath(target_file).resolve()
if not str(absolute_path).startswith(str(directory.resolve())):
if directory not in absolute_path.parents:
raise ResolveException(
f"Path resolved to file outside folder ({absolute_path})"
)