diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2020-12-07 10:00:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 10:00:08 -0500 |
commit | 1f3748f03398f8f91ec5121312aa79dd58306ec1 (patch) | |
tree | 1d9797ac6e1462a761013fcb41ec8518ba55604b /synapse/rest/media | |
parent | Add type hints for HTTP and email pushers. (#8880) (diff) | |
download | synapse-1f3748f03398f8f91ec5121312aa79dd58306ec1.tar.xz |
Do not raise a 500 exception when previewing empty media. (#8883)
Diffstat (limited to 'synapse/rest/media')
-rw-r--r-- | synapse/rest/media/v1/preview_url_resource.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py index dce6c4d168..1082389d9b 100644 --- a/synapse/rest/media/v1/preview_url_resource.py +++ b/synapse/rest/media/v1/preview_url_resource.py @@ -676,7 +676,11 @@ class PreviewUrlResource(DirectServeJsonResource): logger.debug("No media removed from url cache") -def decode_and_calc_og(body, media_uri, request_encoding=None): +def decode_and_calc_og(body, media_uri, request_encoding=None) -> Dict[str, str]: + # If there's no body, nothing useful is going to be found. + if not body: + return {} + from lxml import etree try: |