mirror of
https://github.com/searxng/searxng.git
synced 2025-11-21 22:13:18 -05:00
[fix] searx/results.py - TypeError: object of type 'NoneType' has no len()
In some engines, under certain circumstances, the content field can also have
the value ``None``; in these cases, a length check results in an exception::
File "/usr/local/searxng/searx/results.py", line 360, in merge_two_main_results
if len(other.content) > len(origin.content):
^^^^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
[1] https://github.com/searxng/searxng/issues/5250#issuecomment-3352863488
Reported-by: @scross01 [1]
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
e16b6cb148
commit
748b521ac6
@ -67,7 +67,7 @@ def construct_body(result):
|
||||
)
|
||||
thumbnail = pdbe_preview_url.format(pdb_id=result['pdb_id'])
|
||||
except KeyError:
|
||||
content = None
|
||||
content = ""
|
||||
thumbnail = None
|
||||
|
||||
# construct url for preview image
|
||||
|
||||
@ -357,12 +357,12 @@ def merge_two_infoboxes(origin: LegacyResult, other: LegacyResult):
|
||||
def merge_two_main_results(origin: MainResult | LegacyResult, other: MainResult | LegacyResult):
|
||||
"""Merges the values from ``other`` into ``origin``."""
|
||||
|
||||
if len(other.content) > len(origin.content):
|
||||
if len(other.content or "") > len(origin.content or ""):
|
||||
# use content with more text
|
||||
origin.content = other.content
|
||||
|
||||
# use title with more text
|
||||
if len(other.title) > len(origin.title):
|
||||
if len(other.title or "") > len(origin.title or ""):
|
||||
origin.title = other.title
|
||||
|
||||
# merge all result's parameters not found in origin
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user