@@ -52,6 +52,10 @@ class TestUtils(SearxTestCase):
5252 self.assertIsNotNone(utils.html_to_text(html))
5353 self.assertEqual(utils.html_to_text(html), "Test text")
5454
55+ def test_html_to_text_invalid(self):
56+ html = '<p><b>Lorem ipsum</i>dolor sit amet</p>'
57+ self.assertEqual(utils.html_to_text(html), "Lorem ipsum")
58+
5559 def test_prettify_url(self):
5660 data = (('https://searx.me/', 'https://searx.me/'),
5761 ('https://searx.me/ű', 'https://searx.me/ű'),
@@ -116,6 +120,11 @@ class TestHTMLTextExtractor(SearxTestCase):
116120 self.html_text_extractor.handle_entityref(entity)
117121 self.assertIn(entity, self.html_text_extractor.result)
118122
123+ def test_invalid_html(self):
124+ text = '<p><b>Lorem ipsum</i>dolor sit amet</p>'
125+ with self.assertRaises(utils.HTMLTextExtractorException):
126+ self.html_text_extractor.feed(text)
127+
119128
120129class TestUnicodeWriter(SearxTestCase):
121130