プロジェクト

全般

プロフィール

Vote #75553

完了

PDF export fails if there is U+FFFD in issue data or journals

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
PDF export_39
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
39
version_id:
87
issue_org_id:
17826
author_id:
88801
assigned_to_id:
11192
comments:
14
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
84
ステータス-->[Closed]

説明

When users add special characters to issues (often by copy/pasting text from terminals to issue journals), they cannot export these issues to PDF and get an error (invalid byte sequence in UTF-8).

Here is an example. With these special characters in it, an error should occur when we try to export this issue to PDF.

Archivage automatique         D�sactiv

S�quence de journal en ligne
S�quence de journal courante


journals

New test :

Archivage automatique D�sactiv
Destination de l'archive /uarch
S�quence de journal en ligne la plus ancienne
S�quence de journal courante
--------------------------------------------------------------------------------
The problem occurs on my server (with Redmine 2.5.2 / ruby 2.0.0 and no plugin) but everything seems to work fine here...
--------------------------------------------------------------------------------
Can you try to reproduce: 1/ on redmine 2.5.2 with ruby 1.9.3, 2/ on current trunk ? Anyway the stack trace would be helpful (I have access to this through our common instance but not other contributors ;)). Maybe we can force encoding somewhere.

Note that I'd like to see it reproduced on current trunk because r13358 has extracted the vendored rfpdf plugin and we will use the gem starting with 2.6.0, so I'd like to see if issue is the same with that. But if we can fix that for 2.5.3, let's go then ;-)
--------------------------------------------------------------------------------
PDF export works fine with ruby 1.9.3 and redmine 2.5.2.
The error occurs with ruby 2.0.0 and ruby 2.1.2.

Here is the stack trace:

ArgumentError (invalid byte sequence in UTF-8):
lib/plugins/rfpdf/lib/tcpdf.rb:3037:in `gsub'
lib/plugins/rfpdf/lib/tcpdf.rb:3037:in `escape'
lib/plugins/rfpdf/lib/tcpdf.rb:3028:in `escapetext'
lib/plugins/rfpdf/lib/tcpdf.rb:1748:in `Cell'
lib/plugins/rfpdf/lib/tcpdf.rb:2021:in `Write'
lib/plugins/rfpdf/lib/tcpdf.rb:3530:in `block in writeHTML'
lib/plugins/rfpdf/lib/tcpdf.rb:3501:in `each'
lib/plugins/rfpdf/lib/tcpdf.rb:3501:in `writeHTML'
lib/plugins/rfpdf/lib/tcpdf.rb:3612:in `writeHTMLCell'
lib/redmine/export/pdf.rb:141:in `RDMwriteHTMLCell'
lib/redmine/export/pdf.rb:601:in `issue_to_pdf'
app/controllers/issues_controller.rb:133:in `block (2 levels) in show'
app/controllers/issues_controller.rb:125:in `show'

I will try with the last version from trunk.
--------------------------------------------------------------------------------
Vincent Robert wrote:
> PDF export works fine with ruby 1.9.3 and redmine 2.5.2.
> The error occurs with ruby 2.0.0 and ruby 2.1.2.
>
> Here is the stack trace:
>
> ArgumentError (invalid byte sequence in UTF-8):
> lib/plugins/rfpdf/lib/tcpdf.rb:3037:in `gsub'
> lib/plugins/rfpdf/lib/tcpdf.rb:3037:in `escape'
> lib/plugins/rfpdf/lib/tcpdf.rb:3028:in `escapetext'
> lib/plugins/rfpdf/lib/tcpdf.rb:1748:in `Cell'
> lib/plugins/rfpdf/lib/tcpdf.rb:2021:in `Write'
> lib/plugins/rfpdf/lib/tcpdf.rb:3530:in `block in writeHTML'
> lib/plugins/rfpdf/lib/tcpdf.rb:3501:in `each'
> lib/plugins/rfpdf/lib/tcpdf.rb:3501:in `writeHTML'
> lib/plugins/rfpdf/lib/tcpdf.rb:3612:in `writeHTMLCell'
> lib/redmine/export/pdf.rb:141:in `RDMwriteHTMLCell'
> lib/redmine/export/pdf.rb:601:in `issue_to_pdf'
> app/controllers/issues_controller.rb:133:in `block (2 levels) in show'
> app/controllers/issues_controller.rb:125:in `show'
>
> I will try with the last version from trunk.

I think your ruby 2.0.0 and 2.1.2 are broken.
Because Redmine 2.5 uses 'ASCII-8BIT'.
source:tags/2.5.2/lib/redmine/export/pdf.rb#L787
--------------------------------------------------------------------------------
I cannot reproduce.
<pre>
$ ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
</pre>

!pdf-issue-notes.png!
--------------------------------------------------------------------------------
Did you try with Redmine 2.5.2?

It appears the error is gone with trunk version of Redmine. It only occurs with 2.5.2 and ruby > 2.0.0 (I reproduced the bug on my Mac, but also on a linux server and even on Heroku ;)
--------------------------------------------------------------------------------
Try this patch.
<pre><code class="diff">
diff --git a/lib/plugins/rfpdf/lib/tcpdf.rb b/lib/plugins/rfpdf/lib/tcpdf.rb
--- a/lib/plugins/rfpdf/lib/tcpdf.rb
+++ b/lib/plugins/rfpdf/lib/tcpdf.rb
@@ -1,3 +1,5 @@
+# encoding: ascii-8bit
+
#============================================================+
# File name : tcpdf.rb
# Begin : 2002-08-03

</code></pre>
--------------------------------------------------------------------------------
Vincent Robert wrote:
> Did you try with Redmine 2.5.2?

Sorry, I can reproduce on Redmine 2.5.

--------------------------------------------------------------------------------
Great! It works perfectly with this patch.
--------------------------------------------------------------------------------

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

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

--------------------------------------------------------------------------------
Fixed in 2.5-stable r13370 and 2.4-stable r13371, thanks.
--------------------------------------------------------------------------------

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

いいね!0
いいね!0