Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix error when downloading thumbnail with width/height param missing #5258

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions changelog.d/5258.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error when downloading thumbnail with missing width/height parameter.
5 changes: 5 additions & 0 deletions synapse/rest/media/v1/thumbnail_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from twisted.web.resource import Resource
from twisted.web.server import NOT_DONE_YET

from synapse.api.errors import Codes, SynapseError
from synapse.http.server import set_cors_headers, wrap_json_request_handler
from synapse.http.servlet import parse_integer, parse_string

Expand Down Expand Up @@ -61,6 +62,10 @@ def _async_render_GET(self, request):
method = parse_string(request, "method", "scale")
m_type = parse_string(request, "type", "image/png")

if None in (width, height):
message = "Missing width and/or height param"
raise SynapseError(400, message, Codes.MISSING_PARAM)

if server_name == self.server_name:
if self.dynamic_thumbnails:
yield self._select_or_generate_local_thumbnail(
Expand Down