mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 19:47:14 +00:00
Add support for quoted arguments containing commas in wiki macros (#40014).
Patch by Yasu Saku (user:skys). git-svn-id: https://svn.redmine.org/redmine/trunk@22959 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
65597ec1cf
commit
578360fdab
@ -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]
|
||||
|
||||
@ -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'
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user