X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/b2d342589a7889a3b096e7192453d53bd28eed7d..0dc56b4d4622e08b88ba9189501de265d1e6ae08:/src/search/views.py?ds=sidebyside diff --git a/src/search/views.py b/src/search/views.py index c6759ea76..5b65a3006 100644 --- a/src/search/views.py +++ b/src/search/views.py @@ -132,11 +132,18 @@ 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( 'catalogue/search_too_short.html', {'prefix': query}, context_instance=RequestContext(request)) + elif len(query) > 256: + return render_to_response( + 'catalogue/search_too_long.html', {'prefix': query}, context_instance=RequestContext(request)) query = remove_query_syntax_chars(query)