From e273c0d73f7e2df100f67c8351a35bdd87860e58 Mon Sep 17 00:00:00 2001 From: Ocean Date: Mon, 16 Feb 2026 22:50:12 +0100 Subject: [PATCH] fix: add disposition type to Content-Disposition header (RFC 2183) The Content-Disposition header was set to 'filename="name.ext"' without a disposition type, violating RFC 2183. This caused third-party HTTP clients (e.g. Go's mime.ParseMediaType) to fail parsing the filename. Added 'inline;' disposition type prefix to all Content-Disposition headers in the /view endpoint. Fixes #8914 --- server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index 8882e43c4919..7c13607d90d4 100644 --- a/server.py +++ b/server.py @@ -523,7 +523,7 @@ async def view_image(request): buffer.seek(0) return web.Response(body=buffer.read(), content_type=f'image/{image_format}', - headers={"Content-Disposition": f"filename=\"{filename}\""}) + headers={"Content-Disposition": f"inline; filename=\"{filename}\""}) if 'channel' not in request.rel_url.query: channel = 'rgba' @@ -543,7 +543,7 @@ async def view_image(request): buffer.seek(0) return web.Response(body=buffer.read(), content_type='image/png', - headers={"Content-Disposition": f"filename=\"{filename}\""}) + headers={"Content-Disposition": f"inline; filename=\"{filename}\""}) elif channel == 'a': with Image.open(file) as img: @@ -560,7 +560,7 @@ async def view_image(request): alpha_buffer.seek(0) return web.Response(body=alpha_buffer.read(), content_type='image/png', - headers={"Content-Disposition": f"filename=\"{filename}\""}) + headers={"Content-Disposition": f"inline; filename=\"{filename}\""}) else: # Get content type from mimetype, defaulting to 'application/octet-stream' content_type = mimetypes.guess_type(filename)[0] or 'application/octet-stream' @@ -572,7 +572,7 @@ async def view_image(request): return web.FileResponse( file, headers={ - "Content-Disposition": f"filename=\"{filename}\"", + "Content-Disposition": f"inline; filename=\"{filename}\"", "Content-Type": content_type } )