Example #1
0
    def test_links_stripped(self):
        # Link with markup.
        s = u'a <a href="http://example.com">link</a> with markup'
        x = NoLinksNoMarkupTranslation(localized_string=s)
        eq_(x.__html__(), u'a  with markup')

        # Text link.
        s = u'a text http://example.com link'
        x = NoLinksNoMarkupTranslation(localized_string=s)
        eq_(x.__html__(), u'a text  link')

        # Text link, markup link, 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 forbidden tags</b>, '
             u'<script>forbidden tags</script> and <http://bad.markup.com')
        x = NoLinksNoMarkupTranslation(localized_string=s)
        eq_(x.__html__(), u'a  with markup, a text  link, '
                          u'&lt;b&gt;with forbidden tags&lt;/b&gt;, '
                          u'&lt;script&gt;forbidden tags&lt;/script&gt; and')
Example #2
0
    def test_links_stripped(self):
        # Link with markup.
        s = u'a <a href="http://example.com">link</a> with markup'
        x = NoLinksNoMarkupTranslation(localized_string=s)
        eq_(x.__html__(), u'a  with markup')

        # Text link.
        s = u'a text http://example.com link'
        x = NoLinksNoMarkupTranslation(localized_string=s)
        eq_(x.__html__(), u'a text  link')

        # Text link, markup link, 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 forbidden tags</b>, '
             u'<script>forbidden tags</script> and <http://bad.markup.com')
        x = NoLinksNoMarkupTranslation(localized_string=s)
        eq_(x.__html__(), u'a  with markup, a text  link, '
                          u'&lt;b&gt;with forbidden tags&lt;/b&gt;, '
                          u'&lt;script&gt;forbidden tags&lt;/script&gt; and')
Example #3
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script> <b>bold</b>'
     x = NoLinksNoMarkupTranslation(localized_string=s)
     eq_(x.__html__(),
         '&lt;script&gt;some naughty xss&lt;/script&gt; '
         '&lt;b&gt;bold&lt;/b&gt;')
Example #4
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script> <b>bold</b>'
     x = NoLinksNoMarkupTranslation(localized_string=s)
     eq_(
         x.__html__(), '&lt;script&gt;some naughty xss&lt;/script&gt; '
         '&lt;b&gt;bold&lt;/b&gt;')