]> source.dussan.org Git - redmine.git/commitdiff
Replace closing html tags with html entity (#910).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 13 Apr 2008 12:45:17 +0000 (12:45 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 13 Apr 2008 12:45:17 +0000 (12:45 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1348 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redcloth.rb
test/unit/helpers/application_helper_test.rb

index 5ed23b8f783cc36447e4ff4ffef57e98d0db216d..7e0c718397713fecd339080137fe72f2f01ab9b2 100644 (file)
@@ -1134,7 +1134,7 @@ class RedCloth < String
     ALLOWED_TAGS = %w(redpre pre code)
     
     def escape_html_tags(text)
-      text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "&lt;#{$1}" }
+      text.gsub!(%r{<(\/?(\w+)[^>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "&lt;#{$1}#{'&gt;' if $3}" }
     end
 end
 
index 66499c0034110f4d55f8ffb3132b26e5f3a74b6d..f0de341c6cd0663e720467d5e0e09da9630bd08e 100644 (file)
@@ -134,8 +134,9 @@ class ApplicationHelperTest < HelperTestCase
   
   def test_html_tags
     to_test = {
-      "<div>content</div>" => "<p>&lt;div>content&lt;/div></p>",
-      "<script>some script;</script>" => "<p>&lt;script>some script;&lt;/script></p>",
+      "<div>content</div>" => "<p>&lt;div&gt;content&lt;/div&gt;</p>",
+      "<div class=\"bold\">content</div>" => "<p>&lt;div class=\"bold\"&gt;content&lt;/div&gt;</p>",
+      "<script>some script;</script>" => "<p>&lt;script&gt;some script;&lt;/script&gt;</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>",