From 231158eaffe94dc4cb46601ec229318c2266758a Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 22 Jun 2017 16:57:27 +0200 Subject: [PATCH] sanitize whitespace and cut private use chars in search query --- src/search/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/search/views.py b/src/search/views.py index 67c3fd48f..20b5e8823 100644 --- a/src/search/views.py +++ b/src/search/views.py @@ -132,6 +132,10 @@ def hint(request): @cache.never_cache def main(request): query = request.GET.get('q', '') + query = ' '.join(query.split()) + # filter out private use characters + import unicodedata + query = ''.join(ch for ch in query if unicodedata.category(ch) == 'Co') if len(query) < 2: return render_to_response( -- 2.20.1