aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/text_helper_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2010-02-12 17:24:04 -0800
committerDavid Heinemeier Hansson <david@loudthinking.com>2010-02-12 17:24:04 -0800
commitd68f8ba5c303556ecb8625dd146184d68b704e83 (patch)
treebd0360f2f04c1a732c24687afed0366d38a5d5fc /actionpack/test/template/text_helper_test.rb
parent325fa58ef585b4303a41270e231918f298ee30bd (diff)
downloadrails-d68f8ba5c303556ecb8625dd146184d68b704e83.tar.gz
rails-d68f8ba5c303556ecb8625dd146184d68b704e83.tar.bz2
rails-d68f8ba5c303556ecb8625dd146184d68b704e83.zip
simple_format returns a safe buffer escaping unsafe input [Santiago Pastorino]
Diffstat (limited to 'actionpack/test/template/text_helper_test.rb')
-rw-r--r--actionpack/test/template/text_helper_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb
index 39bea12501..9962b7af3f 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionpack/test/template/text_helper_test.rb
@@ -40,6 +40,18 @@ class TextHelperTest < ActionView::TestCase
assert_equal %Q(<p class="test">para 1</p>\n\n<p class="test">para 2</p>), simple_format("para 1\n\npara 2", :class => 'test')
end
+ def test_simple_format_should_be_html_safe
+ assert simple_format("<b> test with html tags </b>").html_safe?
+ end
+
+ def test_simple_format_should_escape_unsafe_input
+ assert_equal "<p>&lt;b&gt; test with unsafe string &lt;/b&gt;</p>", simple_format("<b> test with unsafe string </b>")
+ end
+
+ def test_simple_format_should_not_escape_safe_input
+ assert_equal "<p><b> test with safe string </b></p>", simple_format("<b> test with safe string </b>".html_safe)
+ end
+
def test_truncate
assert_equal "Hello World!", truncate("Hello World!", :length => 12)
assert_equal "Hello Wor...", truncate("Hello World!!", :length => 12)