summaryrefslogtreecommitdiff
path: root/searx/plugins
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2025-01-28 14:21:55 +0100
committerMarkus Heiser <markus.heiser@darmarIT.de>2025-01-28 16:28:12 +0100
commit906b9e7d4c87dcb7ded4ef1248e9569caf408cc7 (patch)
treef2f15c87528632b38116a58cc5bcb41e74be97f5 /searx/plugins
parent36a1ef12399d529f210ceb4f8b28f497fabd0834 (diff)
[fix] hostnames plugin: AttributeError: 'NoneType' object has no attribute 'netloc'
Closes: https://github.com/searxng/searxng/issues/4245 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/plugins')
-rw-r--r--searx/plugins/ahmia_filter.py2
-rw-r--r--searx/plugins/hostnames.py6
2 files changed, 4 insertions, 4 deletions
diff --git a/searx/plugins/ahmia_filter.py b/searx/plugins/ahmia_filter.py
index 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 True
result_hash = md5(result['parsed_url'].hostname.encode()).hexdigest()
return result_hash not in ahmia_blacklist
diff --git a/searx/plugins/hostnames.py b/searx/plugins/hostnames.py
index 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):
continue
url_src = urlparse(result[url_field])
@@ -164,7 +164,7 @@ def on_result(_request, _search, result) -> bool:
return False
for url_field in _url_fields:
- if not result.get(url_field):
+ if not getattr(result, url_field, None):
continue
url_src = urlparse(result[url_field])