def clean_bio(self): bio = self.cleaned_data['bio'] normalized = clean_nl(unicode(bio)) if has_links(normalized): # There's some links, we don't want them. raise forms.ValidationError(_('No links are allowed.')) return bio
def clean(self): from amo.utils import clean_nl super(PurifiedTranslation, self).clean() cleaned = bleach.clean(self.localized_string) linkified = bleach.linkify(cleaned, nofollow=True, filter_url=urlresolvers.get_outgoing_url) self.localized_string_clean = clean_nl(linkified).strip()
def clean_description(self): description = self.cleaned_data['description'] normalized = clean_nl(description) if has_links(normalized): # There's some links, we don't want them. raise forms.ValidationError(_('No links are allowed.')) return description
def clean(self): from amo.utils import clean_nl super(PurifiedTranslation, self).clean() cleaned = bleach.clean(self.localized_string) callbacks = [nofollow, urlresolvers.get_outgoing_url_for_bleach] linkified = bleach.linkify(cleaned, callbacks=callbacks) self.localized_string_clean = clean_nl(linkified).strip()
def no_links(string): """Leave text links untouched, keep only inner text on URLs.""" if not string: return string if hasattr(string, '__html__'): string = string.__html__() no_links = remove_tags(string, 'a A') return jinja2.Markup(clean_nl(no_links).strip())
def clean(self): from amo.utils import clean_nl super(PurifiedTranslation, self).clean() try: cleaned = bleach.clean(self.localized_string) except Exception as e: log.error('Failed to clean %s: %r' % (self.localized_string, e), exc_info=sys.exc_info()) cleaned = '' linkified = urlresolvers.linkify_with_outgoing(cleaned) self.localized_string_clean = clean_nl(linkified).strip()
def clean(self): from amo.utils import clean_nl super(PurifiedTranslation, self).clean() cleaned = self.clean_localized_string() self.localized_string_clean = clean_nl(cleaned).strip()
def clean(string): from amo.utils import clean_nl return jinja2.Markup(clean_nl(bleach.clean(unicode(string))).strip())
def clean(string): return jinja2.Markup(clean_nl(bleach.clean(unicode(string))).strip())