diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/conf/global_settings.py | 4 | ||||
| -rw-r--r-- | django/core/validators.py | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index dee39867c6..ff691410bc 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -272,6 +272,10 @@ CACHE_MIDDLEWARE_KEY_PREFIX = '' COMMENTS_ALLOW_PROFANITIES = False +# The profanities that will trigger a validation error in the +# 'hasNoProfanities' validator. All of these should be in lower-case. +PROFANITIES_LIST = ['asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit'] + # The group ID that designates which users are banned. # Set to None if you're not using it. COMMENTS_BANNED_USERS_GROUP = None diff --git a/django/core/validators.py b/django/core/validators.py index 8f40ceb51a..6a8418848b 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -227,9 +227,8 @@ def hasNoProfanities(field_data, all_data): catch 'motherfucker' as well. Raises a ValidationError such as: Watch your mouth! The words "f--k" and "s--t" are not allowed here. """ - bad_words = ['asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit'] # all in lower case field_data = field_data.lower() # normalize - words_seen = [w for w in bad_words if field_data.find(w) > -1] + words_seen = [w for w in settings.PROFANITIES_LIST if field_data.find(w) > -1] if words_seen: from django.utils.text import get_text_list plural = len(words_seen) > 1 |
