Unverified Commit 2ad635b6 authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by GitHub
Browse files

Merge pull request #236 from jelly/search

packages: fix negative and invalid limit in search API
parents 4b93ee3d 01f0f69c
......@@ -17,7 +17,7 @@
class PackageSearchForm(forms.Form):
limit = forms.CharField(required=False)
limit = forms.IntegerField(required=False, min_value=0)
page = forms.CharField(required=False)
repo = forms.MultipleChoiceField(required=False)
arch = forms.MultipleChoiceField(required=False)
......@@ -163,8 +163,8 @@ def search_json(request):
form = PackageSearchForm(data=request.GET,
show_staging=request.user.is_authenticated)
if form.is_valid():
form_limit = form.cleaned_data['limit']
limit = min(limit, int(form_limit)) if form_limit else limit
form_limit = form.cleaned_data.get('limit', limit)
limit = min(limit, form_limit) if form_limit else limit
container['limit'] = limit
packages = Package.objects.select_related('arch', 'repo',
......
Supports Markdown
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