From fb7c904c0bfbb4fea459fa4e9640048268871b34 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sun, 16 Dec 2018 16:10:40 +0100 Subject: [PATCH] Don't crash on an incorrectly quoted suburl parameter --- pgweb/search/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pgweb/search/views.py b/pgweb/search/views.py index b69353cc..a89d7cd5 100644 --- a/pgweb/search/views.py +++ b/pgweb/search/views.py @@ -289,10 +289,17 @@ def search(request): hits = curs.fetchall() conn.close() totalhits = int(hits[-1][5]) + try: + if quoted_suburl: + quoted_suburl = urllib.quote_plus(suburl) + else: + quoted_suburl = '' + except: + quoted_suburl = '' querystr = "?q=%s&a=%s&u=%s" % ( urllib.quote_plus(query.encode('utf-8')), allsites and "1" or "0", - suburl and urllib.quote_plus(suburl) or '', + quoted_suburl, ) return render(request, 'search/sitesearch.html', { -- 2.39.5