From 5bcccfde6c8e32b0186a072074c13fbeb51c0d04 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 5 Aug 2016 14:45:11 +0100 Subject: [PATCH] Don't include html comments in description --- synapse/rest/media/v1/preview_url_resource.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py index 4060593f7f..bdd0e60c5b 100644 --- a/synapse/rest/media/v1/preview_url_resource.py +++ b/synapse/rest/media/v1/preview_url_resource.py @@ -345,7 +345,8 @@ class PreviewUrlResource(Resource): # lines) text_nodes = ( re.sub(r'\s+', '\n', el.text).strip() - for el in cloned_tree.iter() if el.text + for el in cloned_tree.iter() + if el.text and isinstance(el.tag, basestring) # Removes comments ) og['og:description'] = summarize_paragraphs(text_nodes)