summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-03-16 19:25:38 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-03-16 19:25:38 +0000
commit699d6fc2f63dc7d12bf8962b3d2773e05c5679ff (patch)
tree068dadaa08c34c323dad4f642172a17fb3e351ab /synapse
parentMerge pull request #6331 from matrix-org/rav/url_preview_limit_title (diff)
parentMerge pull request #6334 from matrix-org/rav/url_preview_limit_title_2 (diff)
downloadsynapse-699d6fc2f63dc7d12bf8962b3d2773e05c5679ff.tar.xz
Merge pull request #6334 from matrix-org/rav/url_preview_limit_title_2
* commit '5570d1c93':
  Fix exception when OpenGraph tag values are ints
Diffstat (limited to 'synapse')
-rw-r--r--synapse/rest/media/v1/preview_url_resource.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py
index 69544b3711..15c15a12f5 100644
--- a/synapse/rest/media/v1/preview_url_resource.py
+++ b/synapse/rest/media/v1/preview_url_resource.py
@@ -278,7 +278,8 @@ class PreviewUrlResource(DirectServeResource):
         # filter out any stupidly long values
         keys_to_remove = []
         for k, v in og.items():
-            if len(k) > OG_TAG_NAME_MAXLEN or len(v) > OG_TAG_VALUE_MAXLEN:
+            # values can be numeric as well as strings, hence the cast to str
+            if len(k) > OG_TAG_NAME_MAXLEN or len(str(v)) > OG_TAG_VALUE_MAXLEN:
                 logger.warning(
                     "Pruning overlong tag %s from OG data", k[:OG_TAG_NAME_MAXLEN]
                 )