@@ -385,13 +385,13 @@ def test_should_sanitize_attributes
385
385
386
386
def test_should_sanitize_illegal_style_properties
387
387
raw = %(display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:1; background-color:black; background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg); background-x:center; background-y:center; background-repeat:repeat;)
388
- expected = %(display: block; width: 100%; height: 100%; background-color: black; background-x: center; background-y: center;)
388
+ expected = %(display:block;width:100%;height:100%;background-color:black;background-x:center;background-y:center;)
389
389
assert_equal expected , sanitize_css ( raw )
390
390
end
391
391
392
392
def test_should_sanitize_with_trailing_space
393
393
raw = "display:block; "
394
- expected = "display: block;"
394
+ expected = "display:block;"
395
395
assert_equal expected , sanitize_css ( raw )
396
396
end
397
397
@@ -484,6 +484,38 @@ def test_allow_data_attribute_if_requested
484
484
assert_equal %(<a data-foo="foo">foo</a>) , white_list_sanitize ( text , attributes : [ 'data-foo' ] )
485
485
end
486
486
487
+ def test_uri_escaping_of_href_attr_in_a_tag_in_white_list_sanitizer
488
+ html = %{<a href='examp<!--" unsafeattr=foo()>-->le.com'>test</a>}
489
+
490
+ text = white_list_sanitize ( html )
491
+
492
+ assert_equal %{<a href="examp<!--%22%20unsafeattr=foo()>-->le.com">test</a>} , text
493
+ end
494
+
495
+ def test_uri_escaping_of_src_attr_in_a_tag_in_white_list_sanitizer
496
+ html = %{<a src='examp<!--" unsafeattr=foo()>-->le.com'>test</a>}
497
+
498
+ text = white_list_sanitize ( html )
499
+
500
+ assert_equal %{<a src="examp<!--%22%20unsafeattr=foo()>-->le.com">test</a>} , text
501
+ end
502
+
503
+ def test_uri_escaping_of_name_attr_in_a_tag_in_white_list_sanitizer
504
+ html = %{<a name='examp<!--" unsafeattr=foo()>-->le.com'>test</a>}
505
+
506
+ text = white_list_sanitize ( html )
507
+
508
+ assert_equal %{<a name="examp<!--%22%20unsafeattr=foo()>-->le.com">test</a>} , text
509
+ end
510
+
511
+ def test_uri_escaping_of_name_action_in_a_tag_in_white_list_sanitizer
512
+ html = %{<a action='examp<!--" unsafeattr=foo()>-->le.com'>test</a>}
513
+
514
+ text = white_list_sanitize ( html , attributes : [ 'action' ] )
515
+
516
+ assert_equal %{<a action="examp<!--%22%20unsafeattr=foo()>-->le.com">test</a>} , text
517
+ end
518
+
487
519
protected
488
520
489
521
def xpath_sanitize ( input , options = { } )
0 commit comments