def clean(self): """ Override clean form to bleach :return: cleaned data """ cleaned_data = super(ContentNodeEditForm, self).clean() full_html = self.current_user and self.current_user.has_perm("ninecms.use_full_html") for field in ("title", "highlight", "alias"): if field in cleaned_data: cleaned_data[field] = sanitize(cleaned_data[field], allow_html=False) for field in ("summary", "body"): if field in cleaned_data: cleaned_data[field] = sanitize(cleaned_data[field], full_html=full_html) return cleaned_data
def clean(self): """ Additionally to Django clean() (https://docs.djangoproject.com/en/1.7/ref/forms/validation/) Sanitize HTML from form data (http://stackoverflow.com/questions/5641901/sanitizing-html-in-submitted-form-data) Otherwise the template will escape without stripping if not so specified :return: cleaned data """ cleaned_data = super(ContactForm, self).clean() for field in ("sender_name", "sender_email", "message", "redirect"): if field in cleaned_data: cleaned_data[field] = sanitize(cleaned_data[field], allow_html=False) if "subject" in cleaned_data: cleaned_data["subject"] = "[Website Feedback] " + sanitize(cleaned_data["subject"], allow_html=False) return cleaned_data
def clean(self): """ Additionally to Django clean() (https://docs.djangoproject.com/en/1.7/ref/forms/validation/) Sanitize HTML from form data (http://stackoverflow.com/questions/5641901/sanitizing-html-in-submitted-form-data) Otherwise the template will escape without stripping if not so specified :return: cleaned data """ cleaned_data = super(ContactForm, self).clean() for field in ('sender_name', 'sender_email', 'message', 'redirect'): if field in cleaned_data: cleaned_data[field] = sanitize(cleaned_data[field], allow_html=False) if 'subject' in cleaned_data: cleaned_data['subject'] = "[Website Feedback] " + sanitize( cleaned_data['subject'], allow_html=False) return cleaned_data
def clean(self): """ Override clean form to bleach :return: cleaned data """ cleaned_data = super(ContentNodeEditForm, self).clean() full_html = self.current_user and self.current_user.has_perm( 'ninecms.use_full_html') for field in ('title', 'highlight', 'alias'): if field in cleaned_data: cleaned_data[field] = sanitize(cleaned_data[field], allow_html=False) for field in ('summary', 'body'): if field in cleaned_data: cleaned_data[field] = sanitize(cleaned_data[field], full_html=full_html) return cleaned_data
def clean(self): """ Override clean function to sanitize data :return: cleaned data """ cleaned_data = super(forms.Form, self).clean() if "q" in cleaned_data: cleaned_data["q"] = sanitize(cleaned_data["q"], allow_html=False) return cleaned_data
def clean(self): """ Override clean function to sanitize data :return: cleaned data """ cleaned_data = super(forms.Form, self).clean() if 'q' in cleaned_data: cleaned_data['q'] = sanitize(cleaned_data['q'], allow_html=False) return cleaned_data