diff --git a/scipost/forms.py b/scipost/forms.py index 58279b0c78b551d5e9b74e6ec4c7dbbcf148d925..5c0ea177d1e0650cc391eaba8f66685787181d29 100644 --- a/scipost/forms.py +++ b/scipost/forms.py @@ -4,6 +4,7 @@ __license__ = "AGPL v3" import datetime import pyotp +import re from django import forms from django.contrib.auth import authenticate @@ -701,6 +702,10 @@ class SearchForm(HayStackSearchForm): if not self.cleaned_data.get("q"): 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() + sqs = self.searchqueryset.auto_query(self.cleaned_data["q"]) if self.load_all: