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