diff options
author | Marcin Bachry <hegel666@gmail.com> | 2016-12-14 22:38:18 +0100 |
---|---|---|
committer | Marcin Bachry <hegel666@gmail.com> | 2016-12-14 22:38:18 +0100 |
commit | 24c16fc3494ce91ba97a06f5d42cdea1c4c38c93 (patch) | |
tree | fadb35dae7b6276937c0e88f0415aa3d52fb88f0 /tests | |
parent | Fixup membership query (diff) | |
download | synapse-24c16fc3494ce91ba97a06f5d42cdea1c4c38c93.tar.xz |
Fix crash in url preview when html tag has no text
Signed-off-by: Marcin Bachry <hegel666@gmail.com>
Diffstat (limited to '')
-rw-r--r-- | tests/test_preview.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/test_preview.py b/tests/test_preview.py index ffa52e5dd4..5bd36c74aa 100644 --- a/tests/test_preview.py +++ b/tests/test_preview.py @@ -215,3 +215,53 @@ class PreviewUrlTestCase(unittest.TestCase): u"og:title": u"Foo", u"og:description": u"Some text." }) + + def test_missing_title(self): + html = u""" + <html> + <body> + Some text. + </body> + </html> + """ + + og = decode_and_calc_og(html, "http://example.com/test.html") + + self.assertEquals(og, { + u"og:title": None, + u"og:description": u"Some text." + }) + + def test_h1_as_title(self): + html = u""" + <html> + <meta property="og:description" content="Some text."/> + <body> + <h1>Title</h1> + </body> + </html> + """ + + og = decode_and_calc_og(html, "http://example.com/test.html") + + self.assertEquals(og, { + u"og:title": u"Title", + u"og:description": u"Some text." + }) + + def test_missing_title_and_broken_h1(self): + html = u""" + <html> + <body> + <h1><a href="foo"/></h1> + Some text. + </body> + </html> + """ + + og = decode_and_calc_og(html, "http://example.com/test.html") + + self.assertEquals(og, { + u"og:title": None, + u"og:description": u"Some text." + }) |