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