mirror of https://gitlab.com/litecord/litecord.git
channel.messages: fix possible bugs in extract_limit
This commit is contained in:
parent
4580aed97c
commit
50d177e04d
|
|
@ -16,11 +16,12 @@ log = Logger(__name__)
|
||||||
bp = Blueprint('channel_messages', __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."""
|
||||||
try:
|
try:
|
||||||
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()
|
raise ValueError()
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
raise BadRequest('limit not int')
|
raise BadRequest('limit not int')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue