Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] utils: truncated result (#4949)

Ivan Gabaldon49fdf4edd9b5
diff --git a/searx/utils.py b/searx/utils.py
index 3c60851fa..7b7cd8f5d 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -161,9 +161,11 @@ def html_to_text(html_str: str) -> str:
s = _HTMLTextExtractor()
try:
s.feed(html_str)
+ s.close()
except AssertionError:
s = _HTMLTextExtractor()
s.feed(escape(html_str, quote=True))
+ s.close()
except _HTMLTextExtractorException:
logger.debug("HTMLTextExtractor: invalid HTML\n%s", html_str)
return s.get_text()