Prevent exception when remote media Content-Type header value is None

This commit is contained in:
Andrew Morgan 2024-10-23 10:42:54 +01:00
parent a5e16a4ab5
commit 0f0259e60f

View file

@ -912,7 +912,11 @@ class MediaRepository:
) )
raise SynapseError(502, "Failed to fetch remote media") raise SynapseError(502, "Failed to fetch remote media")
if b"Content-Type" in headers: if (
b"Content-Type" in headers
and len(headers[b"Content-Type"]) > 0
and headers[b"Content-Type"][0] is not None
):
media_type = headers[b"Content-Type"][0].decode("ascii") media_type = headers[b"Content-Type"][0].decode("ascii")
else: else:
media_type = "application/octet-stream" media_type = "application/octet-stream"