]> source.dussan.org Git - redmine.git/commitdiff
Fixes #880: code tags not formatted correctly in the wiki (broken by r1216).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 17 Mar 2008 23:01:35 +0000 (23:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 17 Mar 2008 23:01:35 +0000 (23:01 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1271 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 7e88007a6828bb89596ca99b9b33a828d971bc7d..14940cb884c598facf45e66223a82c04cac1255a 100644 (file)
@@ -1130,7 +1130,7 @@ class RedCloth < String
         end
     end
     
-    ALLOWED_TAGS = %w(redpre pre)
+    ALLOWED_TAGS = %w(redpre pre code)
     
     def escape_html_tags(text)
       text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "&lt;#{$1}" }
index 0a63c811e184db7633c993ee07189d3d362e62cc..2b90b8f4b8072ba4a9359989e42b78c4d5b0d2f4 100644 (file)
@@ -132,6 +132,19 @@ class ApplicationHelperTest < HelperTestCase
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
   end
   
+  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>",
+      # 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>&lt;div&gt;content&lt;/div&gt;</pre>",
+    }
+    to_test.each { |text, result| assert_equal result, textilizable(text) }
+
+  end
+  
   def test_macro_hello_world
     text = "{{hello_world}}"
     assert textilizable(text).match(/Hello world!/)