Skip to content
Snippets Groups Projects
Unverified Commit ea6d376c authored by Fredrik Jonsson's avatar Fredrik Jonsson Committed by GitHub
Browse files

Merge pull request #1148 from OpenTechFund/fix/invalid-literal-for-int-people-and-news

Add checks that person_type and news_type queries are numerical and i…
parents 71aa15d3 5d4880c6
No related branches found
No related tags found
No related merge requests found
...@@ -142,7 +142,7 @@ class NewsIndex(BasePage): ...@@ -142,7 +142,7 @@ class NewsIndex(BasePage):
'authors__author', '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')) news = news.filter(news_types__news_type=request.GET.get('news_type'))
# Pagination # Pagination
......
...@@ -218,7 +218,7 @@ class PersonIndexPage(BasePage): ...@@ -218,7 +218,7 @@ class PersonIndexPage(BasePage):
'person_types__person_type', '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')) people = people.filter(person_types__person_type=request.GET.get('person_type'))
if not request.GET.get('include_inactive') == 'true': if not request.GET.get('include_inactive') == 'true':
......
import re
from django.conf import settings from django.conf import settings
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.http import Http404 from django.http import Http404
...@@ -17,6 +19,10 @@ def search(request): ...@@ -17,6 +19,10 @@ def search(request):
# Search # Search
if search_query: 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 public_site = request.site.root_page
search_results = Page.objects.live().descendant_of( search_results = Page.objects.live().descendant_of(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment