Fixed: Wiki headings containing backslash followed by a digit are not displayed correctly (#7846).

Contributed by Etienne Massip.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5100 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-03-12 18:28:30 +00:00
parent 1423890735
commit 7db930f1b4
2 changed files with 13 additions and 5 deletions

View File

@ -707,11 +707,13 @@ class RedCloth3 < String
atts = pba( atts ) atts = pba( atts )
# pass to prefix handler # pass to prefix handler
replacement = nil
if respond_to? "textile_#{ tag }", true if respond_to? "textile_#{ tag }", true
text.gsub!( $&, method( "textile_#{ tag }" ).call( tag, atts, cite, content ) ) replacement = method( "textile_#{ tag }" ).call( tag, atts, cite, content )
elsif respond_to? "textile_#{ tagpre }_", true elsif respond_to? "textile_#{ tagpre }_", true
text.gsub!( $&, method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) ) replacement = method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content )
end end
text.gsub!( $& ) { replacement } if replacement
end end
end end

View File

@ -64,12 +64,18 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
'@<Location /redmine>@' => '<code>&lt;Location /redmine&gt;</code>' '@<Location /redmine>@' => '<code>&lt;Location /redmine&gt;</code>'
) )
end end
def test_escaping def test_escaping
assert_html_output( assert_html_output(
'this is a <script>' => 'this is a &lt;script&gt;' 'this is a <script>' => 'this is a &lt;script&gt;'
) )
end end
def test_use_of_backslashes_followed_by_numbers_in_headers
assert_html_output({
'h1. 2009\02\09' => '<h1>2009\02\09</h1>'
}, false)
end
def test_double_dashes_should_not_strikethrough def test_double_dashes_should_not_strikethrough
assert_html_output( assert_html_output(
@ -88,9 +94,9 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
private private
def assert_html_output(to_test) def assert_html_output(to_test, expect_paragraph = true)
to_test.each do |text, expected| to_test.each do |text, expected|
assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n" assert_equal(( expect_paragraph ? "<p>#{expected}</p>" : expected ), @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n")
end end
end end
end end