fix(gallery): confine gallery image path resolution (#4352)

This commit is contained in:
RaresKeY
2026-06-16 05:28:09 +03:00
committed by GitHub
parent 6b7a4c1e70
commit 745c10e0d7
2 changed files with 16 additions and 8 deletions
-8
View File
@@ -67,14 +67,6 @@ def _gallery_image_path(filename: str) -> Path:
raise HTTPException(400, "Unsafe gallery filename")
if safe_name != original:
raise HTTPException(400, "Unsafe gallery filename")
if not path.exists():
cwd_root = (Path.cwd() / "data" / "generated_images").resolve()
cwd_path = (cwd_root / safe_name).resolve()
try:
if os.path.commonpath([str(cwd_root), str(cwd_path)]) == str(cwd_root) and cwd_path.exists():
return cwd_path
except Exception:
pass
return path