mirror of
https://github.com/searxng/searxng.git
synced 2026-05-23 19:34:31 +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:
|
def response(resp: "SXNG_Response") -> EngineResults:
|
||||||
res = 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
|
# hide sponsored results
|
||||||
if result.get("sponsored", False):
|
if result.get("sponsored", False):
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user