SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] hardening against arguments of type None, where str or dict is expected
Markus Heisere6308b8167e2
diff --git a/searx/engines/presearch.py b/searx/engines/presearch.pyindex 034233163..1093b5cff 100644--- a/searx/engines/presearch.py+++ b/searx/engines/presearch.py@@ -184,6 +184,8 @@ def _fix_title(title, url):def parse_search_query(json_results):results = []+ if not json_results:+ return resultsfor item in json_results.get('specialSections', {}).get('topStoriesCompact', {}).get('data', []):result = {@@ -245,7 +247,7 @@ def response(resp):json_resp = resp.json()if search_type == 'search':- results = parse_search_query(json_resp.get('results'))+ results = parse_search_query(json_resp.get('results', {}))elif search_type == 'images':for item in json_resp.get('images', []):diff --git a/searx/result_types/_base.py b/searx/result_types/_base.pyindex caf7e2a4f..ce846c3cf 100644--- a/searx/result_types/_base.py+++ b/searx/result_types/_base.py@@ -103,8 +103,10 @@ def _normalize_text_fields(result: MainResult | LegacyResult):result.content = str(result)# normalize title and content- result.title = WHITESPACE_REGEX.sub(" ", result.title).strip()- result.content = WHITESPACE_REGEX.sub(" ", result.content).strip()+ if result.title:+ result.title = WHITESPACE_REGEX.sub(" ", result.title).strip()+ if result.content:+ result.content = WHITESPACE_REGEX.sub(" ", result.content).strip()if result.content == result.title:# avoid duplicate content between the content and title fieldsresult.content = ""diff --git a/searx/utils.py b/searx/utils.pyindex ee044704b..a28171a32 100644--- a/searx/utils.py+++ b/searx/utils.py@@ -154,6 +154,8 @@ def html_to_text(html_str: str) -> str:>>> html_to_text(r'regexp: (?<![a-zA-Z]')'regexp: (?<![a-zA-Z]'"""+ if not html_str:+ return ""html_str = html_str.replace('\n', ' ').replace('\r', ' ')html_str = ' '.join(html_str.split())s = _HTMLTextExtractor()diff --git a/searx/webapp.py b/searx/webapp.pyindex b721c7132..23c5d70cc 100755--- a/searx/webapp.py+++ b/searx/webapp.py@@ -265,6 +265,9 @@ def custom_url_for(endpoint: str, **values):def morty_proxify(url: str):+ if not url:+ return url+if url.startswith('//'):url = 'https:' + url@@ -280,6 +283,8 @@ def morty_proxify(url: str):def image_proxify(url: str):+ if not url:+ return urlif url.startswith('//'):url = 'https:' + url