diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 31956bfae..168ce43f7 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -400,7 +400,7 @@ module Redmine gc.stroke('transparent') gc.strokewidth(1) gc.draw('text %d,%d %s' % [ - left.round + 8, 14, Redmine::Utils::Shell.shell_quote("#{month_f.year}-#{month_f.month}") + left.round + 8, 14, image_text_quote("#{month_f.year}-#{month_f.month}") ]) left = left + width month_f = month_f >> 1 @@ -436,7 +436,7 @@ module Redmine gc.stroke('transparent') gc.strokewidth(1) gc.draw('text %d,%d %s' % [ - left.round + 2, header_height + 14, Redmine::Utils::Shell.shell_quote(week_f.cweek.to_s) + left.round + 2, header_height + 14, image_text_quote(week_f.cweek.to_s) ]) left = left + width week_f = week_f + 7 @@ -797,7 +797,7 @@ module Redmine params[:image].stroke('transparent') params[:image].strokewidth(1) params[:image].draw('text %d,%d %s' % [ - params[:indent], params[:top] + 2, Redmine::Utils::Shell.shell_quote(subject) + params[:indent], params[:top] + 2, image_text_quote(subject) ]) end @@ -1040,10 +1040,18 @@ module Redmine if label params[:image].fill('black') params[:image].draw('text %d,%d %s' % [ - params[:subject_width] + (coords[:bar_end] || 0) + 5, params[:top] + 1, Redmine::Utils::Shell.shell_quote(label) + params[:subject_width] + (coords[:bar_end] || 0) + 5, params[:top] + 1, image_text_quote(label) ]) end end + + def image_text_quote(text) + if Redmine::Platform.mswin? + %Q!"#{text.gsub(/(")/, '\\\\\1')}"! + else + %Q!'#{text.gsub(/(')/, '\\\\\1')}'! + end + end end end end diff --git a/test/functional/gantts_controller_test.rb b/test/functional/gantts_controller_test.rb index d89ae52db..1fa5126a2 100644 --- a/test/functional/gantts_controller_test.rb +++ b/test/functional/gantts_controller_test.rb @@ -170,6 +170,7 @@ class GanttsControllerTest < Redmine::ControllerTest if Object.const_defined?(:MiniMagick) && convert_installed? def test_gantt_should_export_to_png + Issue.generate!(:subject => %q!Subject containing special characters " and '!) get( :show, :params => {