##// END OF EJS Templates
Added a regex for validation of tags. This refs #10
neko259 -
r69:dd7c561f default
parent child Browse files
Show More
@@ -1,3 +1,4 b''
1 import re
1 2 from django import forms
2 3 from neboard import settings
3 4
@@ -38,17 +39,17 b' class PostForm(forms.Form):'
38 39
39 40
40 41 class ThreadForm(PostForm):
41 INVALID_TAG_CHARACTERS = ['+', '/', '&', '=', '?', '-', '.', ',']
42 regex_tags = re.compile(r'^[\w\s]+$')
42 43
43 44 tags = forms.CharField(max_length=100)
44 45
45 46 def clean_tags(self):
46 47 tags = self.cleaned_data['tags']
48
47 49 if tags:
48 for character in tags:
49 if character in self.INVALID_TAG_CHARACTERS:
50 raise forms.ValidationError(
51 'Inappropriate characters in tags')
50 if not self.regex_tags.match(tags):
51 raise forms.ValidationError(
52 'Inappropriate characters in tags')
52 53
53 54 return tags
54 55
General Comments 0
You need to be logged in to leave comments. Login now