diff --git a/app/logical/d_text.rb b/app/logical/d_text.rb index e4aeefd22..9349520db 100644 --- a/app/logical/d_text.rb +++ b/app/logical/d_text.rb @@ -179,7 +179,7 @@ class DText else if flags[:code] - block + CGI.escape_html(block) + "\n\n" else '
' + parse_inline(block) + '
' end diff --git a/test/unit/dtext_test.rb b/test/unit/dtext_test.rb index e8bdb1b70..a083b5118 100644 --- a/test/unit/dtext_test.rb +++ b/test/unit/dtext_test.rb @@ -41,6 +41,10 @@ class DTextTest < ActiveSupport::TestCase assert_equal("\n", p("[quote]\na\n[quote]\nb\n[/quote]\nc\n[/quote]")) end + def test_code + assert_equal("a
\n\nb
c
\n
for (i=0; i<5; ++i) {\n printf(1);\n}\n\nexit(1);\n\n", p("[code]for (i=0; i<5; ++i) {\n printf(1);\n}\n\nexit(1);"))
+ end
+
def test_urls
assert_equal('a http://test.com b
', p('a http://test.com b')) assert_equal('', p("http://test.com\nb")) @@ -49,24 +53,13 @@ class DTextTest < ActiveSupport::TestCase assert_equal('a http://test.com. b
', p('a http://test.com. b')) assert_equal('a (http://test.com) b
', p('a (http://test.com) b')) end - - # def test_links - # assert_equal('', p('[url=http://test.com]test[/url]')) - # assert_equal('"1" 2
', p('"1" [url=http://two.com]2[/url]')) - # assert_equal('"1" 2 & 3
', p('"1" [url=http://three.com]2 & 3[/url]')) - # end - + def test_old_syle_links assert_equal('', p('"test":http://test.com')) assert_equal('"1" 2
', p('"1" "2":http://two.com')) assert_equal('"1" 2 & 3
', p('"1" "2 & 3":http://three.com')) end - # def test_aliased_urls - # assert_equal('a bob. b
', p('a [url=http://test.com]bob[/url]. b')) - # assert_equal('', p('[i][url=http://test.com]bob[/url][/i]')) - # end - def test_lists assert_equal('