Fixed: inline code with less-then/greater-than produces @lt; and @gt; (#1416).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3567 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-03-12 15:12:23 +00:00
parent 3dc4dbe302
commit 054ff0db8e
2 changed files with 22 additions and 3 deletions

View File

@ -613,7 +613,7 @@ class RedCloth3 < String
text.gsub!( CODE_RE ) do |m| text.gsub!( CODE_RE ) do |m|
before,lang,code,after = $~[1..4] before,lang,code,after = $~[1..4]
lang = " lang=\"#{ lang }\"" if lang lang = " lang=\"#{ lang }\"" if lang
rip_offtags( "#{ before }<code#{ lang }>#{ code }</code>#{ after }" ) rip_offtags( "#{ before }<code#{ lang }>#{ code }</code>#{ after }", false )
end end
end end
@ -1054,7 +1054,7 @@ class RedCloth3 < String
end end
end end
def rip_offtags( text ) def rip_offtags( text, escape_aftertag=true )
if text =~ /<.*>/ if text =~ /<.*>/
## strip and encode <pre> content ## strip and encode <pre> content
codepre, used_offtags = 0, {} codepre, used_offtags = 0, {}
@ -1068,7 +1068,7 @@ class RedCloth3 < String
@pre_list.last << line @pre_list.last << line
line = "" line = ""
else else
htmlesc( aftertag, :NoQuotes ) if aftertag htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag
line = "<redpre##{ @pre_list.length }>" line = "<redpre##{ @pre_list.length }>"
$3.match(/<#{ OFFTAGS }([^>]*)>/) $3.match(/<#{ OFFTAGS }([^>]*)>/)
tag = $1 tag = $1

View File

@ -60,4 +60,23 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
end end
end end
end end
def test_inline_code
to_test = {
'this is @some code@' => 'this is <code>some code</code>',
'@<Location /redmine>@' => '<code>&lt;Location /redmine&gt;</code>',
}
to_test.each do |text, expected|
assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html
end
end
def test_escaping
to_test = {
'this is a <script>' => 'this is a &lt;script&gt;',
}
to_test.each do |text, expected|
assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html
end
end
end end