Exemple #1
0
 def test_convert_unsafe_html(self):
     """
     <script>alert('Hello');</script> & a "test"
     """
     raw = "<script>alert('Hello');</script> & a \"test\""
     result = make_html_safe(raw)
     expected = ('&lt;script&gt;alert(&#39;Hello&#39;);&lt;/script&gt; ' +
         '&amp; a &#34;test&#34;')
     self.assertEqual(result, expected)
Exemple #2
0
 def test_converts_doublequote(self):
     """
     " becomes &#34;
     """
     result = make_html_safe('"')
     self.assertEqual(result, '&#34;')
Exemple #3
0
 def test_converts_singlequote(self):
     """
     ' becomes &#39;
     """
     result = make_html_safe("'")
     self.assertEqual(result, '&#39;')
Exemple #4
0
 def test_converts_greaterthan(self):
     """
     > becomes &gt;
     """
     result = make_html_safe('>')
     self.assertEqual(result, '&gt;')
Exemple #5
0
 def test_converts_lessthan(self):
     """
     < becomes &lt;
     """
     result = make_html_safe('<')
     self.assertEqual(result, '&lt;')
Exemple #6
0
 def test_converts_ampersand(self):
     """
     & becomes &amp;
     """
     result = make_html_safe('&')
     self.assertEqual(result, '&amp;')