Commit 50d177e0 authored by Luna's avatar Luna 📟

channel.messages: fix possible bugs in extract_limit

parent 4580aed9
......@@ -16,11 +16,12 @@ log = Logger(__name__)
bp = Blueprint('channel_messages', __name__)
def extract_limit(request, default: int = 50):
def extract_limit(request_, default: int = 50, max_val: int = 100):
"""Extract a limit kwarg."""
limit = int(request.args.get('limit', default))
limit = int(request_.args.get('limit', default))
if limit not in range(0, 100):
if limit not in range(0, max_val + 1):
raise ValueError()
except (TypeError, ValueError):
raise BadRequest('limit not int')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment