summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-04-29 07:08:39 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-04-29 07:08:39 +0000
commitaef8228b0eed867c4069a8ce7917f3fcfe01794d (patch)
treeb8b619efbd89495900fdb4d64f7f01ed64b33018
parent20e66521097e88d6ab919004abf65f146b5ebccd (diff)
downloadredmine-aef8228b0eed867c4069a8ce7917f3fcfe01794d.tar.gz
redmine-aef8228b0eed867c4069a8ce7917f3fcfe01794d.zip
Merged r5100 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.1-stable@5572 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/redcloth3.rb6
-rw-r--r--test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb12
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb
index 7c9df0727..848aa7042 100644
--- a/lib/redcloth3.rb
+++ b/lib/redcloth3.rb
@@ -707,11 +707,13 @@ class RedCloth3 < String
atts = pba( atts )
# pass to prefix handler
+ replacement = nil
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
- text.gsub!( $&, method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) )
+ replacement = method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content )
end
+ text.gsub!( $& ) { replacement } if replacement
end
end
diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
index 72cb9dc55..69b410e83 100644
--- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
@@ -64,12 +64,18 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
'@<Location /redmine>@' => '<code>&lt;Location /redmine&gt;</code>'
)
end
-
+
def test_escaping
assert_html_output(
'this is a <script>' => 'this is a &lt;script&gt;'
)
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
assert_html_output(
@@ -88,9 +94,9 @@ class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
private
- def assert_html_output(to_test)
+ def assert_html_output(to_test, expect_paragraph = true)
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