Ejemplo n.º 1
0
    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'&lt;script&gt;forbidden tags&lt;/script&gt; and')
Ejemplo n.º 2
0
    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'&lt;script&gt;forbidden tags&lt;/script&gt; and')
Ejemplo n.º 3
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script>'
     x = NoLinksTranslation(localized_string=s)
     eq_(x.__html__(), '&lt;script&gt;some naughty xss&lt;/script&gt;')
Ejemplo n.º 4
0
 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>')
Ejemplo n.º 5
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script>'
     x = NoLinksTranslation(localized_string=s)
     eq_(x.__html__(), '&lt;script&gt;some naughty xss&lt;/script&gt;')
Ejemplo n.º 6
0
 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>')