@@ -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{<(\/?(\w+)[^>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "<#{$1}#{'>' |
|
1137 | text.gsub!(%r{<(\/?([!\w]+)[^<>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "<#{$1}#{'>' unless $3.blank?}" } | |
1138 | end |
|
1138 | end | |
1139 | end |
|
1139 | end | |
1140 |
|
1140 |
@@ -141,6 +141,8 class ApplicationHelperTest < HelperTestCase | |||||
141 | "<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>", |
|
141 | "<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>", | |
142 | "<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>", | |
143 | "<pre><div>content</div></pre>" => "<pre><div>content</div></pre>", |
|
143 | "<pre><div>content</div></pre>" => "<pre><div>content</div></pre>", | |
|
144 | "HTML comment: <!-- no comments -->" => "<p>HTML comment: <!-- no comments --></p>", | |||
|
145 | "<!-- opening comment" => "<p><!-- opening comment</p>" | |||
144 | } |
|
146 | } | |
145 | to_test.each { |text, result| assert_equal result, textilizable(text) } |
|
147 | to_test.each { |text, result| assert_equal result, textilizable(text) } | |
146 | end |
|
148 | end |
General Comments 0
You need to be logged in to leave comments.
Login now