]> source.dussan.org Git - redmine.git/commitdiff
PDF: nil safe at fix_text_encoding(txt) of lib/redmine/export/pdf.rb.
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 6 Apr 2011 05:52:07 +0000 (05:52 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 6 Apr 2011 05:52:07 +0000 (05:52 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5345 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/export/pdf.rb
test/unit/lib/redmine/export/pdf_test.rb

index 55ab37da46d6676c938f498e80f69dcc506d3254..5ea33e3a89727d95e14f02a99e51bc34ebcf0963 100644 (file)
@@ -143,6 +143,7 @@ module Redmine
         end
 
         def fix_text_encoding(txt)
+          txt ||= ''
           if txt.respond_to?(:force_encoding)
             txt.force_encoding('UTF-8')
             txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
@@ -154,7 +155,7 @@ module Redmine
               @ic.iconv(txt)
             rescue
               txt
-            end || ''
+            end
           end
           # 0x5c char handling
           txt.gsub(/\\/, "\\\\\\\\")
index 0281b6a92614654770605f52aeb9850a99cfff9e..d319ce0ecfeee6afe1194864735983aa118c8feb 100644 (file)
@@ -20,6 +20,13 @@ require File.expand_path('../../../../../test_helper', __FILE__)
 class PdfTest < ActiveSupport::TestCase
   include Redmine::I18n
 
+  def test_fix_text_encoding_nil
+    set_language_if_valid 'ja'
+    pdf = Redmine::Export::PDF::IFPDF.new('ja')
+    assert pdf
+    assert_equal '', pdf.fix_text_encoding(nil)
+  end
+
   def test_fix_text_encoding_backslash_ascii
     set_language_if_valid 'ja'
     pdf = Redmine::Export::PDF::IFPDF.new('ja')