Fixes #880: code tags not formatted correctly in the wiki (broken by r1216).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1271 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1c4bcc5b55
commit
7673d69b96
|
@ -1130,7 +1130,7 @@ class RedCloth < String
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ALLOWED_TAGS = %w(redpre pre)
|
ALLOWED_TAGS = %w(redpre pre code)
|
||||||
|
|
||||||
def escape_html_tags(text)
|
def escape_html_tags(text)
|
||||||
text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "<#{$1}" }
|
text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "<#{$1}" }
|
||||||
|
|
|
@ -132,6 +132,19 @@ class ApplicationHelperTest < HelperTestCase
|
||||||
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_html_tags
|
||||||
|
to_test = {
|
||||||
|
"<div>content</div>" => "<p><div>content</div></p>",
|
||||||
|
"<script>some script;</script>" => "<p><script>some script;</script></p>",
|
||||||
|
# do not escape pre/code tags
|
||||||
|
"<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>",
|
||||||
|
"<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>",
|
||||||
|
"<pre><div>content</div></pre>" => "<pre><div>content</div></pre>",
|
||||||
|
}
|
||||||
|
to_test.each { |text, result| assert_equal result, textilizable(text) }
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def test_macro_hello_world
|
def test_macro_hello_world
|
||||||
text = "{{hello_world}}"
|
text = "{{hello_world}}"
|
||||||
assert textilizable(text).match(/Hello world!/)
|
assert textilizable(text).match(/Hello world!/)
|
||||||
|
|
Loading…
Reference in New Issue