mirror of
https://github.com/searxng/searxng.git
synced 2026-05-07 18:03:51 +02:00
[fix] engine - karmasearch crash when searching with long queries (#5912)
Karmasearch seem to crash when searching with long queries >= 100 characters. The returned JSON is exactly this `["",[]]`, which will crash when trying to access `resp.json()["results"]` Close: https://github.com/searxng/searxng/issues/5911 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
@@ -125,7 +125,11 @@ def _parse_images(result: dict[str, t.Any]) -> LegacyResult:
|
||||
def response(resp: "SXNG_Response") -> EngineResults:
|
||||
res = EngineResults()
|
||||
|
||||
for result in resp.json()["results"]:
|
||||
json_resp: dict[str, t.Any] = resp.json()
|
||||
if not isinstance(json_resp, dict):
|
||||
return res # pyright: ignore[reportUnreachable]
|
||||
|
||||
for result in json_resp["results"]:
|
||||
# hide sponsored results
|
||||
if result.get("sponsored", False):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user