diff --git a/opentech/public/search/views.py b/opentech/public/search/views.py index a3aa058ae5361db6acfb7cd267ee70bd73ff02d9..19e7933a538f621202faa5df28d215ff98da67d1 100644 --- a/opentech/public/search/views.py +++ b/opentech/public/search/views.py @@ -1,3 +1,5 @@ +import re + from django.conf import settings from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.http import Http404 @@ -17,6 +19,10 @@ def search(request): # Search if search_query: + # Allow only word characters and spaces in search query. + words = re.findall('\w+', search_query.strip()) + search_query = ' '.join(words) + public_site = request.site.root_page search_results = Page.objects.live().descendant_of(