summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-11-05 16:46:39 +0000
committerGitHub <noreply@github.com>2019-11-05 16:46:39 +0000
commite78167c94b3f63136f7d0e4f32a05ad1befdc0ec (patch)
treecdfdfbfd73eceb822e4944a9506dd61ce0870f23
parentStrip overlong OpenGraph data from url preview (diff)
downloadsynapse-e78167c94b3f63136f7d0e4f32a05ad1befdc0ec.tar.xz
Apply suggestions from code review
Co-Authored-By: Brendan Abolivier <babolivier@matrix.org>
Co-Authored-By: Erik Johnston <erik@matrix.org>
-rw-r--r--synapse/rest/media/v1/preview_url_resource.py2
-rw-r--r--tests/rest/media/v1/test_url_preview.py1
2 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 6d8c39a410..4d4b3c1462 100644
--- a/synapse/rest/media/v1/preview_url_resource.py
+++ b/synapse/rest/media/v1/preview_url_resource.py
@@ -518,7 +518,7 @@ def _calc_og(tree, media_uri):
         if "content" in tag.attrib:
             # if we've got more than 50 tags, someone is taking the piss
             if len(og) >= 50:
-                logger.warning("skipping OG for page with too many og: tags")
+                logger.warning("Skipping OG for page with too many 'og:' tags")
                 return {}
             og[tag.attrib["property"]] = tag.attrib["content"]
 
diff --git a/tests/rest/media/v1/test_url_preview.py b/tests/rest/media/v1/test_url_preview.py
index da19a8e86f..852b8ab11c 100644
--- a/tests/rest/media/v1/test_url_preview.py
+++ b/tests/rest/media/v1/test_url_preview.py
@@ -279,6 +279,7 @@ class URLPreviewTests(unittest.HomeserverTestCase):
         self.pump()
         self.assertEqual(channel.code, 200)
         res = channel.json_body
+        # We should only see the `og:description` field, as `title` is too long and should be stripped out
         self.assertCountEqual(["og:description"], res.keys())
 
     def test_ipaddr(self):