From afc5c82fefcf7bd3c913f5230111434835952479 Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 23 Jan 2023 01:30:22 +0200 Subject: [PATCH] disable empty searches --- files/routes/search.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/files/routes/search.py b/files/routes/search.py index 9888d212f..1be178f14 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -46,8 +46,9 @@ def searchparse(text): @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) @auth_required def searchposts(v:User): - query = request.values.get("q", '').strip() + if not query: + abort(403, "Empty searches aren't allowed!") try: page = max(1, int(request.values.get("page", 1))) except: abort(400, "Invalid page input!") @@ -174,6 +175,8 @@ def searchposts(v:User): @auth_required def searchcomments(v:User): query = request.values.get("q", '').strip() + if not query: + abort(403, "Empty searches aren't allowed!") try: page = max(1, int(request.values.get("page", 1))) except: abort(400, "Invalid page input!")