diff --git a/opentech/public/news/models.py b/opentech/public/news/models.py index d13c4c2c5b2c7e8bf2c746acea563b91bea80efb..b3871fdf19795700ec206b4780fa66ca74e29367 100644 --- a/opentech/public/news/models.py +++ b/opentech/public/news/models.py @@ -142,7 +142,7 @@ class NewsIndex(BasePage): 'authors__author', ) - if request.GET.get('news_type'): + if request.GET.get('news_type') and request.GET.get('news_type').isdigit(): news = news.filter(news_types__news_type=request.GET.get('news_type')) # Pagination diff --git a/opentech/public/people/models.py b/opentech/public/people/models.py index c8efecf66256cf78170aec2d125cc548bb69a160..bb92bf204bfcb173d7521ec32a92b0ed25a8e4b5 100644 --- a/opentech/public/people/models.py +++ b/opentech/public/people/models.py @@ -218,7 +218,7 @@ class PersonIndexPage(BasePage): 'person_types__person_type', ) - if request.GET.get('person_type'): + if request.GET.get('person_type') and request.GET.get('person_type').isdigit(): people = people.filter(person_types__person_type=request.GET.get('person_type')) if not request.GET.get('include_inactive') == 'true': 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(