##// END OF EJS Templates
Replace closing html tags with html entity (#910)....
Jean-Philippe Lang -
r1333:97fe797ad363
parent child
Show More
@@ -1134,7 +1134,7 class RedCloth < String
1134 1134 ALLOWED_TAGS = %w(redpre pre code)
1135 1135
1136 1136 def escape_html_tags(text)
1137 text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "&lt;#{$1}" }
1137 text.gsub!(%r{<(\/?(\w+)[^>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "&lt;#{$1}#{'&gt;' if $3}" }
1138 1138 end
1139 1139 end
1140 1140
@@ -134,8 +134,9 class ApplicationHelperTest < HelperTestCase
134 134
135 135 def test_html_tags
136 136 to_test = {
137 "<div>content</div>" => "<p>&lt;div>content&lt;/div></p>",
138 "<script>some script;</script>" => "<p>&lt;script>some script;&lt;/script></p>",
137 "<div>content</div>" => "<p>&lt;div&gt;content&lt;/div&gt;</p>",
138 "<div class=\"bold\">content</div>" => "<p>&lt;div class=\"bold\"&gt;content&lt;/div&gt;</p>",
139 "<script>some script;</script>" => "<p>&lt;script&gt;some script;&lt;/script&gt;</p>",
139 140 # do not escape pre/code tags
140 141 "<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>",
141 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