def test_links_stripped(self): # Link with markup. s = u'a <a href="http://example.com">link</a> with markup' x = NoLinksTranslation(localized_string=s) eq_(x.__html__(), u'a with markup') # Text link. s = u'a text http://example.com link' x = NoLinksTranslation(localized_string=s) eq_(x.__html__(), u'a text link') # Text link, markup link, allowed tags, forbidden tags and bad markup. s = (u'a <a href="http://example.com">link</a> with markup, a text ' u'http://example.com link, <b>with allowed tags</b>, ' u'<script>forbidden tags</script> and <http://bad.markup.com') x = NoLinksTranslation(localized_string=s) eq_(x.__html__(), u'a with markup, a text link, ' u'<b>with allowed tags</b>, ' u'<script>forbidden tags</script> and')
def test_forbidden_tags(self): s = u'<script>some naughty xss</script>' x = NoLinksTranslation(localized_string=s) eq_(x.__html__(), '<script>some naughty xss</script>')
def test_allowed_tags(self): s = u'<b>bold text</b> or <code>code</code>' x = NoLinksTranslation(localized_string=s) eq_(x.__html__(), u'<b>bold text</b> or <code>code</code>')