From 6f3bf9c1868af0b4e23fc997cd4aa38de6031d67 Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 9 Apr 2013 18:02:01 -0400 Subject: [PATCH] fixes #1212 --- app/logical/d_text.rb | 2 +- test/unit/dtext_test.rb | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) 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

a

\n

b

\n

c

\n
", p("[quote]\na\n[quote]\nb\n[/quote]\nc\n[/quote]")) end + def test_code + assert_equal("
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('

http://test.com
b

', 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('

test

', 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('

test

', 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('

bob

', p('[i][url=http://test.com]bob[/url][/i]')) - # end - def test_lists assert_equal('', p('* a')) assert_equal('', p("* a\n* b").gsub(/\n/, ""))