SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit de9e55f9 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Broaden search query flagged regex

parent 2b480e6b
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.password_validation import validate_password
from django.contrib.auth.validators import UnicodeUsernameValidator
from django.core.exceptions import ValidationError
from django.http import Http404
from django.utils import timezone
from django.utils.dates import MONTHS
......@@ -703,8 +704,8 @@ class SearchForm(HayStackSearchForm):
return self.no_query_found()
# Block queries matching flagged regex to avoid gunicorn worker timeout
if re.search(r'\w{8,}.www.\w{7,}.cn', self.cleaned_data["q"]):
return self.no_query_found()
if re.search(r'\w+.www.\w+.cn', self.cleaned_data["q"]):
raise Http404
sqs = self.searchqueryset.auto_query(self.cleaned_data["q"])
......
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