diff --git a/lib/redcloth.rb b/lib/redcloth.rb index 7e88007a6..14940cb88 100644 --- a/lib/redcloth.rb +++ b/lib/redcloth.rb @@ -1130,7 +1130,7 @@ class RedCloth < String end end - ALLOWED_TAGS = %w(redpre pre) + ALLOWED_TAGS = %w(redpre pre code) def escape_html_tags(text) text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "<#{$1}" } diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 0a63c811e..2b90b8f4b 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -132,6 +132,19 @@ class ApplicationHelperTest < HelperTestCase to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } end + def test_html_tags + to_test = { + "
content
" => "

<div>content</div>

", + "" => "

<script>some script;</script>

", + # do not escape pre/code tags + "
\nline 1\nline2
" => "
\nline 1\nline2
", + "
\nline 1\nline2
" => "
\nline 1\nline2
", + "
content
" => "
<div>content</div>
", + } + to_test.each { |text, result| assert_equal result, textilizable(text) } + + end + def test_macro_hello_world text = "{{hello_world}}" assert textilizable(text).match(/Hello world!/)