Project

General

Profile

Actions

Defect #117

closed

'\'(char code 0x5c) handling is improper in PDF output

Added by Go MAEDA over 16 years ago. Updated over 16 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

When createing PDF file, '\' may have to be escaped like '\\'.
Redmine perhaps does not escape '\', so we sometimes get malformed output.

Because of this problem, issues which contains specific Japanese multi-byte character whose second byte character is
0x5c are not properly exported PDF file (gets malformed output).

[How to reproduce]

1. Create new issue. Description of the issue is following.

printf("Hello\n");
printf("World.\\n");

2. Export it to PDF. You will see malformed output like this.

printf("Hello ");
printf("World.\n");
Actions #1

Updated by Aruo Miura over 16 years ago

Hi.
I make patch for this problem.
This one can resolve 2 problems:
A:Iconv can't convert multi-byte string include '\'.
B:multi-byte character include 0x5c can't show in PDF.

I check only environments:
WindowsXP SP2/Japanese
ruby 1.8.6-p110
rails 1.2.3
redmine rev.781

Index: ifpdf_helper.rb
=================================================================
==
--- ifpdf_helper.rb     (Revision 781)
+++ ifpdf_helper.rb     (Working copy)
@@ -53,7 +53,13 @@
     def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
       @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
       txt = begin
-        @ic.iconv(txt)
+        txtar = txt.split('\\')
+        txtar << '' if txt[-1] == ?\\
+        txtar2 = []
+        txtar.each{|x|
+          txtar2 << @ic.iconv(x)
+        }
+        txtar2.join('\\').gsub(/\\/, "\\\\\\\\")
       rescue
         txt
       end
Actions #2

Updated by Jean-Philippe Lang over 16 years ago

Your fix (slightly edited) is committed in r813.
Thanks for your help.

Actions #3

Updated by Go MAEDA over 16 years ago

Thanks for your work. The fix is of great benefit to MBCS users.

Although the patch's author is Aruo Miura, my name is
written in svn commit log instead of Miura.

Actions #4

Updated by Jean-Philippe Lang over 16 years ago

Oh, I'm sorry. I didn't notice that the patch was from someone
else.

Big thanks to Aruo Miura :-)

Actions #5

Updated by Aruo Miura over 16 years ago

No problem.
Thanks for your work.

Actions

Also available in: Atom PDF