From ca1582a8b618651787ffb1fdec2c115b686d6c5d Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Mon, 2 Nov 2020 21:59:20 +0200 Subject: [PATCH] Make sure limit is between 1 and 100 We were not properly checking whether the limit was greater than 0 in all cases. --- dspace_statistics_api/app.py | 2 +- dspace_statistics_api/util.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dspace_statistics_api/app.py b/dspace_statistics_api/app.py index 009ee88..0d946df 100644 --- a/dspace_statistics_api/app.py +++ b/dspace_statistics_api/app.py @@ -17,7 +17,7 @@ class AllItemsResource: def on_get(self, req, resp): """Handles GET requests""" # 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 offset = limit * page diff --git a/dspace_statistics_api/util.py b/dspace_statistics_api/util.py index 45fda51..50c349c 100644 --- a/dspace_statistics_api/util.py +++ b/dspace_statistics_api/util.py @@ -108,7 +108,7 @@ def validate_items_post_parameters(req, resp, resource, params): else: raise falcon.HTTPBadRequest( 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: req.context.limit = 100