Skip to content

Commit c47aacb

Browse files
committed
Handle null byte searches
Some vulnerability scanners try to find security issues in all webforms and submit invalid null byte into the search from. This is cleaned out by django and leads to 'q' not being set which gives a 500 error. Check if the 'q' key exists in the cleaned_data if not return an empty list. Signed-off-by: Jelle van der Waa <[email protected]>
1 parent 4678d90 commit c47aacb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/views/search.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def exact_matches(self):
5959
# only do exact match search if 'q' is sole parameter
6060
if self.changed_data != ['q']:
6161
return []
62+
if 'q' not in self.cleaned_data:
63+
return []
6264
return Package.objects.normal().filter(pkgname=self.cleaned_data['q'])
6365

6466

0 commit comments

Comments
 (0)