summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/redmine/wiki_formatting/macros.rb7
-rw-r--r--test/unit/lib/redmine/wiki_formatting/macros_test.rb7
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb
index a6238ef1e..f2b8c297f 100644
--- a/lib/redmine/wiki_formatting/macros.rb
+++ b/lib/redmine/wiki_formatting/macros.rb
@@ -38,7 +38,10 @@ module Redmine
method_name = "macro_#{name}"
unless macro_options[:parse_args] == false
- args = args.split(',').map(&:strip)
+ # Split the arguments by commas, but only if the commas
+ # are not within double quotes
+ args = args.split(/\s*,\s*(?=(?:[^"]*"[^"]*")*[^"]*$)/)
+ .map {|i| i.gsub(/^"(.*)"$/, '\1').gsub('""', '"')}
end
begin
@@ -57,7 +60,7 @@ module Redmine
def extract_macro_options(args, *keys)
options = {}
while args.last.to_s.strip =~ %r{^(.+?)\=(.+)$} && keys.include?($1.downcase.to_sym)
- options[$1.downcase.to_sym] = $2
+ options[$1.downcase.to_sym] = $2.gsub(/^"(.*)"$/, '\1')
args.pop
end
return [args, options]
diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb
index 1355acef3..b385de6fc 100644
--- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb
@@ -279,6 +279,13 @@ class Redmine::WikiFormatting::MacrosTest < Redmine::HelperTest
end
end
+ def test_macro_collapse_with_arg_contains_comma
+ text = %|{{collapse("Click here, to see the example", Hide example)\n*Collapsed* block of text\n}}|
+ result = textilizable(text)
+ assert_select_in result, 'a.collapsible.icon-collapsed', :text => 'Click here, to see the example'
+ assert_select_in result, 'a.collapsible.icon-expanded', :text => 'Hide example'
+ end
+
def test_macro_collapse_should_not_break_toc
set_language_if_valid 'en'