Skip to content

Commit

Permalink
[fix] limit maximum page number of a search query to page 50.
Browse files Browse the repository at this point in the history
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 searxng#2972

Signed-off-by: Markus Heiser <[email protected]>
  • Loading branch information
return42 committed Nov 1, 2023
1 parent 980b43e commit 04c1d39
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion searx/webadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 04c1d39

Please sign in to comment.