1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-22 12:10:11 +01:00

[fix] KeyError: 'title' in results using key-value.html template

Since #2508 a title is required --> this is a bug when an engine uses the
key-value.html template [1], where no title is needed.

[1] https://github.com/searxng/searxng/blob/master/searx/templates/simple/result_templates/key-value.html

Closes: https://github.com/searxng/searxng/issues/3130
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2024-02-04 09:56:23 +01:00 committed by Markus Heiser
parent fcfff92017
commit df1a774003

View File

@ -354,10 +354,13 @@ class ResultContainer:
for result in self._merged_results: for result in self._merged_results:
score = result_score(result) score = result_score(result)
result['score'] = score result['score'] = score
# removing html content and whitespace duplications
if result.get('content'): if result.get('content'):
result['content'] = utils.html_to_text(result['content']).strip() result['content'] = utils.html_to_text(result['content']).strip()
# removing html content and whitespace duplications if result.get('title'):
result['title'] = ' '.join(utils.html_to_text(result['title']).strip().split()) result['title'] = ' '.join(utils.html_to_text(result['title']).strip().split())
for result_engine in result['engines']: for result_engine in result['engines']:
counter_add(score, 'engine', result_engine, 'score') counter_add(score, 'engine', result_engine, 'score')