プロジェクト

全般

プロフィール

Vote #81082

未完了

Escaping symbols in task subject can broke export to Gantt (PNG)

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
Confirmed
優先度:
通常
担当者:
-
カテゴリ:
Gantt_34
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
34
version_id:
33
issue_org_id:
34046
author_id:
443661
assigned_to_id:
0
comments:
4
status_id:
9
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
160
ステータス-->[Confirmed]

説明

Hello there, I think i found a problem with export Gantt to PNG. When I have task's subject with escape characters for example: "Student's Problems with new login page" I receive error (from Redmine logs):

MiniMagick::Error (`convert -size 1125x926 xc:white -stroke transparent -fill black -stroke transparent 
...
-strokewidth 1 -draw text 84,418 'Student'"'"'s Problems with new login page' -fill 
...
red -draw line 516,36 516,925 /tmp/mini_magick20200929-4913-1ne7j9r.png` failed with error:
convert-im6.q16: non-conforming drawing primitive definition `'' @ error/draw.c/RenderMVGContent/4301.
):

lib/redmine/helpers/gantt.rb:381:in `to_image'
app/controllers/gantts_controller.rb:44:in `block (2 levels) in show'
app/controllers/gantts_controller.rb:42:in `show'
lib/redmine/sudo_mode.rb:65:in `sudo_mode'

And when I except this task by filters from Gantt everything is fine. Is there any chances to fix this issue?


journals

--------------------------------------------------------------------------------
It used @Redmine::Utils::Shell.shell_quote@ to escape the subject string, but it was an escaping for the string that cannot be handled by the magick-convert command.
I fixed the special character escaping process as follows.

<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,30492,Replace RMagick with MiniMagick

Admin Redmine さんが約2年前に更新

  • カテゴリGantt_34 にセット
  • 対象バージョンCandidate for next minor release_33 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0