1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2024-11-22 14:25:01 +01:00

Make sure limit is between 1 and 100

We were not properly checking whether the limit was greater than 0
in all cases.
This commit is contained in:
Alan Orth 2020-11-02 21:59:20 +02:00
parent 1904c243a4
commit ca1582a8b6
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 2 additions and 2 deletions

View File

@ -17,7 +17,7 @@ class AllItemsResource:
def on_get(self, req, resp): def on_get(self, req, resp):
"""Handles GET requests""" """Handles GET requests"""
# Return HTTPBadRequest if id parameter is not present and valid # Return HTTPBadRequest if id parameter is not present and valid
limit = req.get_param_as_int("limit", min_value=0, max_value=100) or 100 limit = req.get_param_as_int("limit", min_value=1, max_value=100) or 100
page = req.get_param_as_int("page", min_value=0) or 0 page = req.get_param_as_int("page", min_value=0) or 0
offset = limit * page offset = limit * page

View File

@ -108,7 +108,7 @@ def validate_items_post_parameters(req, resp, resource, params):
else: else:
raise falcon.HTTPBadRequest( raise falcon.HTTPBadRequest(
title="Invalid parameter", title="Invalid parameter",
description='The "limit" parameter is invalid. The value must be an integer between 0 and 100.', description='The "limit" parameter is invalid. The value must be an integer between 1 and 100.',
) )
else: else:
req.context.limit = 100 req.context.limit = 100