From b4976ce91ba003942acd3f285c6b4fb308657a69 Mon Sep 17 00:00:00 2001
From: Santiago Pastorino
test with unsafe string
", simple_format(" test with unsafe string ") + assert_equal "<b> test with unsafe string </b><script>code!</script>
", simple_format(" test with unsafe string ") end def test_simple_format_should_not_sanitize_input_if_safe_option @@ -62,8 +62,7 @@ class TextHelperTest < ActionView::TestCase end def test_truncate_should_sanitize_unsafe_input - assert_equal "Hello World!", truncate("Hello World!", :length => 12) - assert_equal "Hello Wor...", truncate("Hello World!!", :length => 12) + assert_equal "Hello <...", truncate("Hello World!!", :length => 12) end def test_truncate_should_not_sanitize_input_if_safe_option @@ -141,7 +140,7 @@ class TextHelperTest < ActionView::TestCase def test_highlight_should_sanitize_unsafe_input assert_equal( - "This is a beautiful morning", + "This is a beautiful morning<script>code!</script>", highlight("This is a beautiful morning", "beautiful") ) end @@ -190,23 +189,23 @@ class TextHelperTest < ActionView::TestCase def test_highlight_with_html assert_equal( - "This is a beautiful morning, but also a beautiful day
", + "<p>This is a beautiful morning, but also a beautiful day</p>", highlight("This is a beautiful morning, but also a beautiful day
", "beautiful") ) assert_equal( - "This is a beautiful morning, but also a beautiful day
", + "<p>This is a <em>beautiful</em> morning, but also a beautiful day</p>", highlight("This is a beautiful morning, but also a beautiful day
", "beautiful") ) assert_equal( - "This is a beautiful morning, but also a beautiful day
", + "<p>This is a <em class="error">beautiful</em> morning, but also a beautiful <span class="last">day</span></p>", highlight("This is a beautiful morning, but also a beautiful day
", "beautiful") ) assert_equal( - "This is a beautiful morning, but also a beautiful day
", + "<p class="beautiful">This is a beautiful morning, but also a beautiful day</p>", highlight("This is a beautiful morning, but also a beautiful day
", "beautiful") ) assert_equal( - "This is a beautiful morning, but also a beautiful day
", + "<p>This is a beautiful <a href="http://example.com/beautiful#top?what=beautiful%20morning&when=now+then">morning</a>, but also a beautiful day</p>", highlight("This is a beautiful morning, but also a beautiful day
", "beautiful") ) end -- cgit v1.2.3