diff -r 1a1428431cca django/contrib/comments/forms.py
a
|
b
|
|
| 1 | import re |
1 | 2 | import time |
2 | 3 | import datetime |
3 | 4 | |
… |
… |
|
168 | 169 | """ |
169 | 170 | comment = self.cleaned_data["comment"] |
170 | 171 | if settings.COMMENTS_ALLOW_PROFANITIES == False: |
171 | | bad_words = [w for w in settings.PROFANITIES_LIST if w in comment.lower()] |
| 172 | bad_words = [w for w in settings.PROFANITIES_LIST |
| 173 | if re.search(r'\b%s\b' % w, comment, flags=re.IGNORECASE)] |
172 | 174 | if bad_words: |
173 | 175 | plural = len(bad_words) > 1 |
174 | 176 | raise forms.ValidationError(ungettext( |
diff -r 1a1428431cca tests/regressiontests/comment_tests/tests/comment_form_tests.py
a
|
b
|
|
72 | 72 | f = CommentForm(a, data=dict(d, comment="What a rooster!")) |
73 | 73 | self.failIf(f.is_valid()) |
74 | 74 | |
| 75 | # Check for Scunthorpe problem |
| 76 | f = CommentForm(a, data=dict(d, comment="What a brooster!")) |
| 77 | self.failUnless(f.is_valid()) |
| 78 | |
75 | 79 | # Now with COMMENTS_ALLOW_PROFANITIES on |
76 | 80 | settings.COMMENTS_ALLOW_PROFANITIES = True |
77 | 81 | f = CommentForm(a, data=dict(d, comment="What a rooster!")) |