Klurifixus / TheCornerForum

0 stars 1 forks source link

Security #43

Closed Klurifixus closed 10 months ago

Klurifixus commented 10 months ago

Ensure that user inputs, especially in forms like the comment form, are properly validated and sanitized to prevent security issues like SQL injection or XSS attacks.

Klurifixus commented 10 months ago

add : def clean_text(self): text = self.cleaned_data['text']

Example: Add custom validation logic

    if 'badword' in text:
        raise forms.ValidationError("Inappropriate content detected.")
    return text    

BAD_WORDS = [ 'badword1', 'badword2', 'inappropriate', 'offensive phrase',

def clean_text(self): text = self.cleaned_data['text']

# Check if any bad words are present
for bad_word in BAD_WORDS:
    if bad_word in text:
        raise forms.ValidationError("Inappropriate content detected.")

return text

in forms.py