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] hostnames plugin: AttributeError: 'NoneType' object has no attribute 'netloc'
Markus Heiser906b9e7d4c87
diff --git a/searx/engines/dictzone.py b/searx/engines/dictzone.pyindex 83ab28ff2..bda056edd 100644--- a/searx/engines/dictzone.py+++ b/searx/engines/dictzone.py@@ -100,5 +100,6 @@ def response(resp) -> EngineResults:if autotranslate.ok and autotranslate.text:item_list.insert(0, results.types.Translations.Item(text=autotranslate.text))- results.add(results.types.Translations(translations=item_list, url=resp.search_params["url"]))+ if item_list:+ results.add(results.types.Translations(translations=item_list, url=resp.search_params["url"]))return resultsdiff --git a/searx/plugins/ahmia_filter.py b/searx/plugins/ahmia_filter.pyindex c1252b147..3a6d48eed 100644--- a/searx/plugins/ahmia_filter.py+++ b/searx/plugins/ahmia_filter.py@@ -19,7 +19,7 @@ ahmia_blacklist: list = []def on_result(_request, _search, result) -> bool:- if not result.get('is_onion') or not result.get('parsed_url'):+ if not getattr(result, 'is_onion', None) or not getattr(result, 'parsed_url', None):return Trueresult_hash = md5(result['parsed_url'].hostname.encode()).hexdigest()return result_hash not in ahmia_blacklistdiff --git a/searx/plugins/hostnames.py b/searx/plugins/hostnames.pyindex f2d829103..5f88bcd40 100644--- a/searx/plugins/hostnames.py+++ b/searx/plugins/hostnames.py@@ -139,7 +139,7 @@ low_priority: set = _load_regular_expressions('low_priority') or set() # type:def _matches_parsed_url(result, pattern):- return parsed in result and pattern.search(result[parsed].netloc)+ return result[parsed] and (parsed in result and pattern.search(result[parsed].netloc))def on_result(_request, _search, result) -> bool:@@ -151,7 +151,7 @@ def on_result(_request, _search, result) -> bool:# logger.debug(result['url'])for url_field in _url_fields:- if not result.get(url_field):+ if not getattr(result, url_field, None):continueurl_src = urlparse(result[url_field])@@ -164,7 +164,7 @@ def on_result(_request, _search, result) -> bool:return Falsefor url_field in _url_fields:- if not result.get(url_field):+ if not getattr(result, url_field, None):continueurl_src = urlparse(result[url_field])diff --git a/searx/result_types/answer.py b/searx/result_types/answer.pyindex 1042fe00e..a9f580e0e 100644--- a/searx/result_types/answer.py+++ b/searx/result_types/answer.py@@ -116,6 +116,10 @@ class Translations(BaseAnswer, kw_only=True):translations: list[Translations.Item]"""List of translations."""+ def __post_init__(self):+ if not self.translations:+ raise ValueError("Translation does not have an item in the list translations")+class Item(msgspec.Struct, kw_only=True):"""A single element of the translations / a translation. A translationconsists of at least a mandatory ``text`` property (the translation) ,