[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 <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2023-10-29 11:20:41 +01:00 committed by Markus Heiser
parent 9aeae2142b
commit 7e2e335dd1
1 changed files with 1 additions and 1 deletions

View File

@ -45,7 +45,7 @@ def validate_engineref_list(
def parse_pageno(form: Dict[str, str]) -> int: def parse_pageno(form: Dict[str, str]) -> int:
pageno_param = form.get('pageno', '1') 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) raise SearxParameterException('pageno', pageno_param)
return int(pageno_param) return int(pageno_param)