Defect #17826
closedPDF export fails if there is U+FFFD in issue data or journals
0%
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
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
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...
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 ;-)
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.
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
Updated by Toshi MARUYAMA about 10 years ago
- File pdf-issue-notes.png pdf-issue-notes.png added
I cannot reproduce.
$ ruby --version ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
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 ;)
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
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.
Updated by Vincent Robert about 10 years ago
Great! It works perfectly with this patch.
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
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
Updated by Toshi MARUYAMA about 10 years ago
- Target version changed from 2.5.3 to 2.4.7
Updated by Toshi MARUYAMA about 10 years ago
- Status changed from Needs feedback to Closed
- Resolution set to Fixed