Skip to content

Commit 02dd05a

Browse files
committed
Merged in [17490] from rjsparks@nostrum.com:
Basic regex validation on community rule entry form. Fixes ietf-tools#2928. - Legacy-Id: 17512 Note: SVN reference [17490] has been migrated to Git commit 70a20b3
2 parents 98028f8 + 70a20b3 commit 02dd05a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

ietf/community/forms.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from __future__ import absolute_import, print_function, unicode_literals
66

7+
import re
8+
79
from django import forms
810
from django.db.models import Q
911

@@ -94,7 +96,12 @@ def restrict_state(state_type, slug=None):
9496
f.required = True
9597

9698
def clean_text(self):
97-
return self.cleaned_data["text"].strip().lower() # names are always lower case
99+
candidate_text = self.cleaned_data["text"].strip().lower() # names are always lower case
100+
try:
101+
re.compile(candidate_text)
102+
except re.error as e:
103+
raise forms.ValidationError(str(e))
104+
return candidate_text
98105

99106

100107
class SubscriptionForm(forms.ModelForm):

0 commit comments

Comments
 (0)