From 6fb68e43cb352457a83474b72eb1334b29cc84c8 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 21 Sep 2026 14:53:06 +0200 Subject: [PATCH] refac(images): request an unencoded body when fetching remote chat images (#29623) The remote chat-image fetch now asks for an identity-encoded response and skips one that comes back content-encoded. An image whose host stores and echoes a `Content-Encoding` regardless of what the client asks for (an S3 or MinIO object uploaded with that metadata) is no longer inlined; the message is forwarded with the original URL instead, the same way an unreachable image already behaves. --- backend/open_webui/utils/files.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/files.py b/backend/open_webui/utils/files.py index f982da1675..e9c926e5f8 100644 --- a/backend/open_webui/utils/files.py +++ b/backend/open_webui/utils/files.py @@ -75,9 +75,16 @@ async def get_image_base64_from_url(url: str, user=None) -> Optional[str]: # rebinding DNS answer that passed validate_url cannot reach an internal address. async with get_ssrf_safe_session() as session: async with session.get( - url, ssl=AIOHTTP_CLIENT_SESSION_SSL, allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS + url, + ssl=AIOHTTP_CLIENT_SESSION_SSL, + allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS, + headers={'Accept-Encoding': 'identity'}, ) as response: response.raise_for_status() + # Accept-Encoding is only a request; the sender can still compress and pick our decompressed size. + encodings = response.headers.getall('Content-Encoding', ()) + if any(encoding.lower() not in ('', 'identity') for encoding in encodings): + return None image_data = bytearray() total = 0 async for chunk in response.content.iter_chunked(64 * 1024):