@@ -1134,7 +1134,7 class RedCloth < String | |||||
1134 | ALLOWED_TAGS = %w(redpre pre code) |
|
1134 | ALLOWED_TAGS = %w(redpre pre code) | |
1135 |
|
1135 | |||
1136 | def escape_html_tags(text) |
|
1136 | def escape_html_tags(text) | |
1137 |
text.gsub!(%r{<( |
|
1137 | text.gsub!(%r{<(\/?(\w+)[^>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "<#{$1}#{'>' if $3}" } | |
1138 | end |
|
1138 | end | |
1139 | end |
|
1139 | end | |
1140 |
|
1140 |
@@ -134,8 +134,9 class ApplicationHelperTest < HelperTestCase | |||||
134 |
|
134 | |||
135 | def test_html_tags |
|
135 | def test_html_tags | |
136 | to_test = { |
|
136 | to_test = { | |
137 |
"<div>content</div>" => "<p><div |
|
137 | "<div>content</div>" => "<p><div>content</div></p>", | |
138 | "<script>some script;</script>" => "<p><script>some script;</script></p>", |
|
138 | "<div class=\"bold\">content</div>" => "<p><div class=\"bold\">content</div></p>", | |
|
139 | "<script>some script;</script>" => "<p><script>some script;</script></p>", | |||
139 | # do not escape pre/code tags |
|
140 | # do not escape pre/code tags | |
140 | "<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>", |
|
141 | "<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>", | |
141 | "<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>", |
|
142 | "<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>", |
General Comments 0
You need to be logged in to leave comments.
Login now