Esempio n. 1
0
 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
Esempio n. 2
0
 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()
Esempio n. 3
0
 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
Esempio n. 4
0
 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()
Esempio n. 5
0
 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
Esempio n. 6
0
 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
Esempio n. 7
0
 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()
Esempio n. 8
0
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())
Esempio n. 9
0
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())
Esempio n. 10
0
 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()
Esempio n. 11
0
 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()
Esempio n. 12
0
 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()
Esempio n. 13
0
def clean(string):
    from amo.utils import clean_nl
    return jinja2.Markup(clean_nl(bleach.clean(unicode(string))).strip())
Esempio n. 14
0
def clean(string):
    return jinja2.Markup(clean_nl(bleach.clean(unicode(string))).strip())
Esempio n. 15
0
def clean(string):
    from amo.utils import clean_nl
    return jinja2.Markup(clean_nl(bleach.clean(unicode(string))).strip())
Esempio n. 16
0
def clean(string):
    return jinja2.Markup(clean_nl(bleach.clean(unicode(string))).strip())