Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
url_preview: Only extract img tags with an `src`.
Alex Vandiverad8943a64aab
diff --git a/zerver/lib/url_preview/parsers/generic.py b/zerver/lib/url_preview/parsers/generic.pyindex d938114f36d..73acbb89cd9 100644--- a/zerver/lib/url_preview/parsers/generic.py+++ b/zerver/lib/url_preview/parsers/generic.py@@ -41,7 +41,7 @@ class GenericParser(BaseParser):soup = self._soupfirst_h1 = soup.find('h1')if first_h1:- first_image = first_h1.find_next_sibling('img')+ first_image = first_h1.find_next_sibling('img', src=True)if first_image and first_image['src'] != '':return first_image['src']return Nonediff --git a/zerver/tests/test_link_embed.py b/zerver/tests/test_link_embed.pyindex 93321b29687..6beeaac5533 100644--- a/zerver/tests/test_link_embed.py+++ b/zerver/tests/test_link_embed.py@@ -194,6 +194,7 @@ class GenericParserTestCase(ZulipTestCase):<html><body><h1>Main header</h1>+ <img data-src="Not an image"><img src="http://test.com/test.jpg"><div><p>Description text</p>