forked from Icycoide/searxng
[fix] searx.utils.HTMLTextExtractor: invalid HTML don't raise an Exception
Close #2188
This commit is contained in:
parent
ae07f4a211
commit
6deb85072a
2 changed files with 18 additions and 2 deletions
|
@ -52,6 +52,10 @@ class TestUtils(SearxTestCase):
|
|||
self.assertIsNotNone(utils.html_to_text(html))
|
||||
self.assertEqual(utils.html_to_text(html), "Test text")
|
||||
|
||||
def test_html_to_text_invalid(self):
|
||||
html = '<p><b>Lorem ipsum</i>dolor sit amet</p>'
|
||||
self.assertEqual(utils.html_to_text(html), "Lorem ipsum")
|
||||
|
||||
def test_prettify_url(self):
|
||||
data = (('https://searx.me/', 'https://searx.me/'),
|
||||
('https://searx.me/ű', 'https://searx.me/ű'),
|
||||
|
@ -116,6 +120,11 @@ class TestHTMLTextExtractor(SearxTestCase):
|
|||
self.html_text_extractor.handle_entityref(entity)
|
||||
self.assertIn(entity, self.html_text_extractor.result)
|
||||
|
||||
def test_invalid_html(self):
|
||||
text = '<p><b>Lorem ipsum</i>dolor sit amet</p>'
|
||||
with self.assertRaises(utils.HTMLTextExtractorException):
|
||||
self.html_text_extractor.feed(text)
|
||||
|
||||
|
||||
class TestUnicodeWriter(SearxTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue