From 47d5b2f33209d674ba3ea275b931ef31b3f03f9c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 29 Oct 2023 11:20:41 +0100 Subject: [PATCH] [fix] limit maximum page number of a search query to page 50. To test this PR run a local instance and try to query page 51: http://127.0.0.1:8888/search?q=foo&pageno=51 A parameter exception will be raised: searx.exceptions.SearxParameterException: Invalid value "51" for parameter pageno And the client will receive a HTTP 400 (Bad request). Closes https://github.com/searxng/searxng/issues/2972 Signed-off-by: Markus Heiser --- searx/webadapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/webadapter.py b/searx/webadapter.py index 9fbb8ea3e..967ed4429 100644 --- a/searx/webadapter.py +++ b/searx/webadapter.py @@ -45,7 +45,7 @@ def validate_engineref_list( def parse_pageno(form: Dict[str, str]) -> int: pageno_param = form.get('pageno', '1') - if not pageno_param.isdigit() or int(pageno_param) < 1: + if not pageno_param.isdigit() or int(pageno_param) < 1 or int(pageno_param) > 50: raise SearxParameterException('pageno', pageno_param) return int(pageno_param)