server/search: protect against weird page numbers
This commit is contained in:
parent
b382f3398f
commit
b5e9f37450
2 changed files with 5 additions and 0 deletions
|
@ -20,6 +20,8 @@ class SearchExecutor(object):
|
|||
Parse input and return tuple containing total record count and filtered
|
||||
entities.
|
||||
'''
|
||||
page = max(1, int(page))
|
||||
page_size = max(1, int(page_size))
|
||||
filter_query = self._prepare(session, query_text)
|
||||
entities = filter_query \
|
||||
.offset((page - 1) * page_size).limit(page_size).all()
|
||||
|
|
|
@ -134,6 +134,9 @@ class TestUserSearchExecutor(DatabaseTestCase):
|
|||
self.session.add(util.mock_user('u2'))
|
||||
self._test('', 1, 1, 2, ['u1'])
|
||||
self._test('', 2, 1, 2, ['u2'])
|
||||
self._test('', 3, 1, 2, [])
|
||||
self._test('', 0, 1, 2, ['u1'])
|
||||
self._test('', 0, 0, 2, ['u1'])
|
||||
|
||||
def test_order_by_name(self):
|
||||
self.session.add(util.mock_user('u2'))
|
||||
|
|
Loading…
Reference in a new issue