Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gateway/platforms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,10 @@ def validate_media_delivery_path(path: str) -> Optional[str]:
if not candidate:
return None

from tools.environments.local import _msys_to_windows_path

candidate = _msys_to_windows_path(candidate)

try:
expanded = Path(os.path.expanduser(candidate))
except (OSError, RuntimeError, ValueError):
Expand Down
24 changes: 24 additions & 0 deletions tests/gateway/test_platform_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,30 @@ def test_accepts_stale_file_outside_allowlist(self, tmp_path, monkeypatch):

assert BasePlatformAdapter.validate_media_delivery_path(str(notes)) == str(notes.resolve())

def test_accepts_msys_path_after_windows_normalization(
self, tmp_path, monkeypatch,
):
"""Git Bash ``MEDIA:/c/Users/...`` must normalize before pathlib (#47767)."""
self._patch_roots(monkeypatch)
media = tmp_path / "photo.png"
media.write_bytes(b"png")

import tools.environments.local as local_mod

msys_input = "/c/Users/test/photo.png"
monkeypatch.setattr(local_mod, "_IS_WINDOWS", True)

def _fake_msys(path: str) -> str:
assert path == msys_input
return str(media)

monkeypatch.setattr(local_mod, "_msys_to_windows_path", _fake_msys)

assert (
BasePlatformAdapter.validate_media_delivery_path(msys_input)
== str(media.resolve())
)

def test_accepts_any_extension_not_on_denylist(self, tmp_path, monkeypatch):
"""No extension allowlist — .md, .txt, .json, .py all deliver."""
self._patch_roots(monkeypatch)
Expand Down
Loading