]> source.dussan.org Git - redmine.git/commitdiff
Fixed: New multi-line macros regexp is too eager (#11736).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 2 Sep 2012 10:24:56 +0000 (10:24 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 2 Sep 2012 10:24:56 +0000 (10:24 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10276 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/lib/redmine/wiki_formatting/macros_test.rb

index a0e9cac9232699eef16dcdad8f9fbfedd933843f..0ce1cc4263b1aef9862bb843411fbf0918374ad9 100644 (file)
@@ -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)
index 90118490918f5ce9f5747d8b7ae92eecc291c4d7..75376652a317e734c4a710b61693372177ae5884 100644 (file)
@@ -273,4 +273,23 @@ EXPECTED
     text = '{{macro(2)}} !{{macro(2)}} {{hello_world(foo)}}'
     assert_equal '<p>{{macro(2)}} {{macro(2)}} Hello world! Object: NilClass, Arguments: foo and no block of text.</p>', 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
+<p>Hello world! Object: NilClass, Called with no argument and a 12 bytes long block of text.</p>
+<p>Hello world! Object: NilClass, Called with no argument and a 20 bytes long block of text.</p>
+EXPECTED
+
+    assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(text).gsub(%r{[\r\n\t]}, '')
+  end
 end