예제 #1
0
 def test_external_text_link(self, get_outgoing_url_mock):
     get_outgoing_url_mock.return_value = 'http://external.url'
     s = u'<b>markup</b> http://example.com'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(),
         u'<b>markup</b> <a rel="nofollow" '
         u'href="http://external.url">http://example.com</a>')
예제 #2
0
 def test_external_text_link(self):
     s = u'<b>markup</b> http://example.com'
     x = PurifiedTranslation(localized_string=s)
     eq_(
         x.__html__(),
         u'<b>markup</b> <a href="http://example.com">http://example.com</a>'
     )
예제 #3
0
 def test_internal_link(self):
     s = u'<b>markup</b> <a href="http://addons.mozilla.org/foo">bar</a>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(),
         u'<b>markup</b> <a href="http://addons.mozilla.org/foo">bar</a>')
예제 #4
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), '&lt;script&gt;some naughty xss&lt;/script&gt;')
예제 #5
0
 def test_allowed_tags(self):
     s = u'<b>bold text</b> or <code>code</code>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), u'<b>bold text</b> or <code>code</code>')
예제 #6
0
 def test_raw_text(self):
     s = u'   This is some text   '
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), 'This is some text')
예제 #7
0
 def test_internal_link(self):
     s = u'<b>markup</b> <a href="http://addons.mozilla.org/foo">bar</a>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(),
         u'<b>markup</b> <a href="http://addons.mozilla.org/foo">bar</a>')
예제 #8
0
 def test_forbidden_tags(self):
     s = u'<script>some naughty xss</script>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), '&lt;script&gt;some naughty xss&lt;/script&gt;')
예제 #9
0
 def test_allowed_tags(self):
     s = u'<b>bold text</b> or <code>code</code>'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), u'<b>bold text</b> or <code>code</code>')
예제 #10
0
 def test_raw_text(self):
     s = u'   This is some text   '
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(), 'This is some text')
예제 #11
0
 def test_external_text_link(self):
     s = u'<b>markup</b> http://example.com'
     x = PurifiedTranslation(localized_string=s)
     eq_(x.__html__(),
         u'<b>markup</b> '
         u'<a href="http://example.com">http://example.com</a>')