Project

General

Profile

Actions

Defect #17826

closed

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

Added by Vincent Robert about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Toshi MARUYAMA
Category:
PDF export
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

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

Files

pdf-issue-notes.png (22 KB) pdf-issue-notes.png Toshi MARUYAMA, 2014-09-11 14:52
Actions #1

Updated by Vincent Robert about 10 years ago

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

Actions #2

Updated by Vincent Robert about 10 years ago

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...

Actions #3

Updated by Jean-Baptiste Barth about 10 years ago

  • Status changed from New to Needs feedback
  • Assignee set to Jean-Baptiste Barth
  • Target version set to Candidate for next minor release

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 ;-)

Actions #4

Updated by Vincent Robert about 10 years ago

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.

Actions #5

Updated by Toshi MARUYAMA about 10 years ago

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

Actions #6

Updated by Toshi MARUYAMA about 10 years ago

I cannot reproduce.

$ ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

Actions #7

Updated by Vincent Robert about 10 years ago

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 ;)

Actions #8

Updated by Toshi MARUYAMA about 10 years ago

Try this patch.

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

Actions #9

Updated by Toshi MARUYAMA about 10 years ago

Vincent Robert wrote:

Did you try with Redmine 2.5.2?

Sorry, I can reproduce on Redmine 2.5.

Actions #10

Updated by Vincent Robert about 10 years ago

Great! It works perfectly with this patch.

Actions #11

Updated by Toshi MARUYAMA about 10 years ago

  • Assignee changed from Jean-Baptiste Barth to Toshi MARUYAMA
  • Target version changed from Candidate for next minor release to 2.5.3
Actions #12

Updated by Toshi MARUYAMA about 10 years ago

  • Subject changed from PDF export fails if there are some special characters in issue data or journals to PDF export fails if there is U+FFFD in issue data or journals
Actions #13

Updated by Toshi MARUYAMA about 10 years ago

  • Target version changed from 2.5.3 to 2.4.7
Actions #14

Updated by Toshi MARUYAMA about 10 years ago

  • Status changed from Needs feedback to Closed
  • Resolution set to Fixed

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

Actions

Also available in: Atom PDF