예제 #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, '')