示例#1
0
 def test_mixed(self):
     text = '<p><script>alert("xss")</script></p>'
     result = safe_html(text)
     eq_(
         result,
         text
         .replace('<script>', '&lt;script&gt;')
         .replace('</script>', '&lt;/script&gt;')
     )
示例#2
0
 def test_mixed(self):
     text = '<p><script>alert("xss")</script></p>'
     result = safe_html(text)
     eq_(
         result,
         text
         .replace('<script>', '&lt;script&gt;')
         .replace('</script>', '&lt;/script&gt;')
     )
示例#3
0
 def test_disallowed_html(self):
     text = '<script>alert("xss")</script>'
     result = safe_html(text)
     eq_(result, text.replace('<', '&lt;').replace('>', '&gt;'))
示例#4
0
 def test_allowed_html(self):
     text = '<p>This <a href="http://peterbe.com">is</a> a<br>link.</p>'
     result = safe_html(text)
     eq_(result, text)
示例#5
0
 def test_basics(self):
     text = ''
     result = safe_html(text)
     ok_(isinstance(result, jinja2.Markup))
     eq_(result, '')
示例#6
0
 def test_disallowed_html(self):
     text = '<script>alert("xss")</script>'
     result = safe_html(text)
     eq_(result, text.replace('<', '&lt;').replace('>', '&gt;'))
示例#7
0
 def test_allowed_html(self):
     text = '<p>This <a href="http://peterbe.com">is</a> a<br>link.</p>'
     result = safe_html(text)
     eq_(result, text)
示例#8
0
 def test_basics(self):
     text = ''
     result = safe_html(text)
     ok_(isinstance(result, jinja2.Markup))
     eq_(result, '')