@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 597ed13803
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 3, 17:45 UTC

[Core][MM] Do not use urllib3 to parse data URLs (#42535)

Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>

Lukas Geiger committed May 13, 2026 at 23:21 UTC 597ed138033e51355ff4ba49876578df92633c91
1 file changed +15 -15
vllm/multimodal/media/connector.py
+15 -15
@@ -235,14 +235,13 @@ class MediaConnector:
235
236 def _load_data_url(
237 self,
238 - url_spec: Url,
238 + url: str,
239 media_io: MediaIO[_M],
240 ) -> _M: # type: ignore[type-var]
241 - url_spec_path = url_spec.path or ""
242 - data_spec, data = url_spec_path.split(",", 1)
241 + # Format per RFC 2397:
242 + # data:[<mediatype>][;base64],<data>
243 + data_spec, data = url[5:].split(",", 1)
244 media_type, data_type = data_spec.split(";", 1)
244 - # media_type starts with a leading "/" (e.g., "/video/jpeg")
245 - media_type = media_type.lstrip("/")
245
246 if data_type != "base64":
247 msg = "Only base64 data URLs are supported for now."
@@ -290,6 +289,9 @@ class MediaConnector:
289 *,
290 fetch_timeout: int | None = None,
291 ) -> _M: # type: ignore[type-var]
292 + if url[:5].lower() == "data:":
293 + return self._load_data_url(url, media_io)
294 +
295 url_spec = parse_url(url)
296
297 if url_spec.scheme and url_spec.scheme.startswith("http"):
@@ -309,9 +311,6 @@ class MediaConnector:
311 self._put_cached_bytes(url, data)
312 return media_io.load_bytes(data)
313
312 - if url_spec.scheme == "data":
313 - return self._load_data_url(url_spec, media_io)
314 -
314 if url_spec.scheme == "file":
315 return self._load_file_url(url_spec, media_io)
316
@@ -325,9 +324,16 @@ class MediaConnector:
324 *,
325 fetch_timeout: int | None = None,
326 ) -> _M:
328 - url_spec = parse_url(url)
327 loop = asyncio.get_running_loop()
328
329 + if url[:5].lower() == "data:":
330 + future = loop.run_in_executor(
331 + global_thread_pool, self._load_data_url, url, media_io
332 + )
333 + return await future
334 +
335 + url_spec = parse_url(url)
336 +
337 if url_spec.scheme and url_spec.scheme.startswith("http"):
338 self._assert_url_in_allowed_media_domains(url_spec)
339
@@ -353,12 +359,6 @@ class MediaConnector:
359 future = loop.run_in_executor(global_thread_pool, media_io.load_bytes, data)
360 return await future
361
356 - if url_spec.scheme == "data":
357 - future = loop.run_in_executor(
358 - global_thread_pool, self._load_data_url, url_spec, media_io
359 - )
360 - return await future
361 -
362 if url_spec.scheme == "file":
363 future = loop.run_in_executor(
364 global_thread_pool, self._load_file_url, url_spec, media_io