Fix relative allowed local media paths (#45263)
Matti4 committed
Jun 26, 2026 at 05:45 UTC
1502cf62749cb3ec1cbf00f7ef87c55b2edd2c84
2 files changed
+18
-1
tests/multimodal/media/test_connector.py
+17
@@ -152,6 +152,23 @@ async def test_fetch_image_local_files(image_url: str):
152
connector.fetch_image(f"file://{temp_dir}/../{os.path.basename(image_url)}")
153
154
155
+@pytest.mark.asyncio
156
+async def test_fetch_image_local_files_relative_allowed_path(tmp_path, monkeypatch):
157
+ media_dir = tmp_path / "media"
158
+ media_dir.mkdir()
159
+ image_path = media_dir / "image.png"
160
+ Image.new("RGB", (1, 1), color=(255, 0, 0)).save(image_path)
161
+
162
+ monkeypatch.chdir(tmp_path)
163
+ local_connector = MediaConnector(allowed_local_media_path="media")
164
+
165
+ image_sync = local_connector.fetch_image(image_path.as_uri())
166
+ image_async = await local_connector.fetch_image_async(image_path.as_uri())
167
+
168
+ assert image_sync.size == (1, 1)
169
+ assert not ImageChops.difference(image_sync, image_async).getbbox()
170
+
171
+
172
@pytest.mark.asyncio
173
@pytest.mark.parametrize("image_url", [TEST_IMAGE_ASSETS[0]], indirect=True)
174
async def test_fetch_image_local_files_with_space_in_name(image_url: str):
vllm/multimodal/media/connector.py
+1
-1
@@ -105,7 +105,7 @@ class MediaConnector:
105
self.connection = connection
106
107
if allowed_local_media_path:
108
- allowed_local_media_path_ = Path(allowed_local_media_path)
108
+ allowed_local_media_path_ = Path(allowed_local_media_path).resolve()
109
110
if not allowed_local_media_path_.exists():
111
raise ValueError(