mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: assert offset and per_page are positive
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
parent
f6c4891415
commit
4d0a982c51
3 changed files with 19 additions and 4 deletions
|
@ -48,7 +48,7 @@ async def requests(
|
|||
if not dict(request.query_params).keys() & FILTER_PARAMS:
|
||||
filter_pending = True
|
||||
|
||||
O, PP = util.sanitize_params(O, PP)
|
||||
O, PP = util.sanitize_params(str(O), str(PP))
|
||||
context["O"] = O
|
||||
context["PP"] = PP
|
||||
context["filter_pending"] = filter_pending
|
||||
|
|
|
@ -96,14 +96,14 @@ def apply_all(iterable: Iterable, fn: Callable):
|
|||
return iterable
|
||||
|
||||
|
||||
def sanitize_params(offset: str, per_page: str) -> Tuple[int, int]:
|
||||
def sanitize_params(offset_str: str, per_page_str: str) -> Tuple[int, int]:
|
||||
try:
|
||||
offset = int(offset)
|
||||
offset = defaults.O if int(offset_str) < 0 else int(offset_str)
|
||||
except ValueError:
|
||||
offset = defaults.O
|
||||
|
||||
try:
|
||||
per_page = int(per_page)
|
||||
per_page = defaults.PP if int(per_page_str) < 0 else int(per_page_str)
|
||||
except ValueError:
|
||||
per_page = defaults.PP
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue