[fix] Startpage engine fails when date field is string (not integer: TypeError) (#6053)

In order to avoid an abort with an error, type- and value- errors are catched,
the publishDate cannot then be determined, but the result item remains.

[1] https://github.com/searxng/searxng/pull/5980/changes#r3091479655

Replaces the PRs:

- https://github.com/searxng/searxng/pull/5980
- https://github.com/searxng/searxng/pull/6006

Closes: https://github.com/searxng/searxng/issues/5979

Suggested-by: @Bnyro [1]

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser
2026-05-07 14:56:14 +02:00
committed by GitHub
parent ea63c19b27
commit 130cea600d
+4 -1
View File
@@ -345,7 +345,10 @@ def _get_news_result(result):
publishedDate = None publishedDate = None
if result.get("date"): if result.get("date"):
publishedDate = datetime.fromtimestamp(result["date"] / 1000) try:
publishedDate = datetime.fromtimestamp(int(result["date"]) / 1000)
except (TypeError, ValueError):
pass
thumbnailUrl = None thumbnailUrl = None
if result.get("thumbnailUrl"): if result.get("thumbnailUrl"):