Example #1
0
 def test_escaping_hash(self):
     # http://2.example.org#frag2
     assert_equal(
         render_mandates(
             {'mandate': json.dumps(['http://2.example.org#frag2'])}),
         '<a href="http://2.example.org#frag2" target="_blank">http://2.example.org#frag2</a>'
     )
Example #2
0
 def test_escaping_invalid_chars(self):
     assert_equal(
         render_mandates({
             'mandate':
             json.dumps(['http://example.com"><script src="nasty.js">'])
         }),
         '<a href="http://example.com&#34;&gt;&lt;script src=&#34;nasty.js&#34;&gt;" target="_blank">http://example.com&#34;&gt;&lt;script src=&#34;nasty.js&#34;&gt;</a>'
     )
Example #3
0
 def test_escaping_umlaut(self):
     # http://www.example.org/Durst (umlaut on the u)
     assert_equal(
         render_mandates(
             {'mandate':
              json.dumps(['http://www.example.org/D\u00fcrst'])}),
         '<a href="http://www.example.org/D\\u00fcrst" target="_blank">http://www.example.org/D\\u00fcrst</a>'
     )
Example #4
0
 def test_escaping_spaces_and_symbols(self):
     # http://www.example.org/foo bar/qux<>?\^`{|}
     assert_equal(
         render_mandates({
             'mandate':
             json.dumps(['http://www.example.org/foo bar/qux<>?\\\^`{|}'])
         }),
         '<a href="http://www.example.org/foo bar/qux&lt;&gt;?\\\\^`{|}" target="_blank">http://www.example.org/foo bar/qux&lt;&gt;?\\\\^`{|}</a>'
     )
Example #5
0
 def test_multiple(self):
     assert_equal(
         render_mandates({
             'mandate':
             json.dumps(['http://example.com/a', 'http://example.com/b'])
         }),
         '<a href="http://example.com/a" target="_blank">http://example.com/a</a><br>'
         '<a href="http://example.com/b" target="_blank">http://example.com/b</a>'
     )
Example #6
0
 def test_escaping_invalid_chars(self):
     assert_equal(render_mandates(
         {'mandate': json.dumps(['http://example.com"><script src="nasty.js">'])}),
         '<a href="http://example.com&#34;&gt;&lt;script src=&#34;nasty.js&#34;&gt;" target="_blank">http://example.com&#34;&gt;&lt;script src=&#34;nasty.js&#34;&gt;</a>')
Example #7
0
 def test_single(self):
     assert_equal(
         render_mandates({'mandate': json.dumps(['http://example.com'])}),
         '<a href="http://example.com" target="_blank">http://example.com</a>'
     )
Example #8
0
 def test_escaping_hash(self):
     # http://2.example.org#frag2
     assert_equal(render_mandates(
         {'mandate': json.dumps(['http://2.example.org#frag2'])}),
         '<a href="http://2.example.org#frag2" target="_blank">http://2.example.org#frag2</a>')
Example #9
0
 def test_escaping_spaces_and_symbols(self):
     # http://www.example.org/foo bar/qux<>?\^`{|}
     assert_equal(render_mandates(
         {'mandate': json.dumps(['http://www.example.org/foo bar/qux<>?\\\^`{|}'])}),
         '<a href="http://www.example.org/foo bar/qux&lt;&gt;?\\\\^`{|}" target="_blank">http://www.example.org/foo bar/qux&lt;&gt;?\\\\^`{|}</a>')
Example #10
0
 def test_escaping_umlaut(self):
     # http://www.example.org/Durst (umlaut on the u)
     assert_equal(render_mandates(
         {'mandate': json.dumps(['http://www.example.org/D\u00fcrst'])}),
         '<a href="http://www.example.org/D\\u00fcrst" target="_blank">http://www.example.org/D\\u00fcrst</a>')
Example #11
0
 def test_multiple(self):
     assert_equal(render_mandates(
         {'mandate': json.dumps(['http://example.com/a', 'http://example.com/b'])}),
         '<a href="http://example.com/a" target="_blank">http://example.com/a</a><br>'
         '<a href="http://example.com/b" target="_blank">http://example.com/b</a>')
Example #12
0
 def test_single(self):
     assert_equal(render_mandates(
         {'mandate': json.dumps(['http://example.com'])}),
         '<a href="http://example.com" target="_blank">http://example.com</a>')