From 8b72710d7ee3c0a5bf0ab20c5fc774482ae47930 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 2 Sep 2012 10:24:56 +0000 Subject: [PATCH] Fixed: New multi-line macros regexp is too eager (#11736). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10276 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 2 +- .../redmine/wiki_formatting/macros_test.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a0e9cac92..0ce1cc426 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -867,7 +867,7 @@ module ApplicationHelper \{\{ # opening tag ([\w]+) # macro name (\(([^\n\r]*?)\))? # optional arguments - ([\n\r].*[\n\r])? # optional block of text + ([\n\r].*?[\n\r])? # optional block of text \}\} # closing tag ) )/mx unless const_defined?(:MACROS_RE) diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb index 901184909..75376652a 100644 --- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb @@ -273,4 +273,23 @@ EXPECTED text = '{{macro(2)}} !{{macro(2)}} {{hello_world(foo)}}' assert_equal '

{{macro(2)}} {{macro(2)}} Hello world! Object: NilClass, Arguments: foo and no block of text.

', textilizable(text) end + + def test_macros_with_text_should_not_mangle_following_macros + text = <<-RAW +{{hello_world +Line of text +}} + +{{hello_world +Another line of text +}} +RAW + + expected = <<-EXPECTED +

Hello world! Object: NilClass, Called with no argument and a 12 bytes long block of text.

+

Hello world! Object: NilClass, Called with no argument and a 20 bytes long block of text.

+EXPECTED + + assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(text).gsub(%r{[\r\n\t]}, '') + end end