From e0fd94a55b2211f0e648773733ae6966c0be372a Mon Sep 17 00:00:00 2001 From: qedk <1994constant@gmail.com> Date: Fri, 12 Jun 2020 03:48:34 +0530 Subject: [PATCH] Trim and validate query Closes #234 --- wikipedia/wikipedia.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wikipedia/wikipedia.py b/wikipedia/wikipedia.py index 7ad50e1..7661378 100644 --- a/wikipedia/wikipedia.py +++ b/wikipedia/wikipedia.py @@ -89,7 +89,11 @@ def search(query, results=10, suggestion=False): * results - the maxmimum number of results returned * suggestion - if True, return results and suggestion (if any) in a tuple ''' - + + query = query.strip() + if len(query) == 0: + raise WikipediaException('Query parameter must not be empty.') + search_params = { 'list': 'search', 'srprop': '',