Basic regex validation on community rule entry form. Fixes #2928. Commit ready for merge.
- Legacy-Id: 17490
This commit is contained in:
parent
ebdadf38f2
commit
70a20b3e8c
|
@ -4,6 +4,8 @@
|
|||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import re
|
||||
|
||||
from django import forms
|
||||
from django.db.models import Q
|
||||
|
||||
|
@ -94,7 +96,12 @@ class SearchRuleForm(forms.ModelForm):
|
|||
f.required = True
|
||||
|
||||
def clean_text(self):
|
||||
return self.cleaned_data["text"].strip().lower() # names are always lower case
|
||||
candidate_text = self.cleaned_data["text"].strip().lower() # names are always lower case
|
||||
try:
|
||||
re.compile(candidate_text)
|
||||
except re.error as e:
|
||||
raise forms.ValidationError(str(e))
|
||||
return candidate_text
|
||||
|
||||
|
||||
class SubscriptionForm(forms.ModelForm):
|
||||
|
|
Loading…
Reference in a new issue