]> source.dussan.org Git - redmine.git/commitdiff
2.4-stable: pdf: fix failure exporting issue pdf with UTF-8 U+FFFD (#17826)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 11 Sep 2014 14:55:24 +0000 (14:55 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 11 Sep 2014 14:55:24 +0000 (14:55 +0000)
This revision has trunk r13368 and r13369 test.

git-svn-id: http://svn.redmine.org/redmine/branches/2.4-stable@13371 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/plugins/rfpdf/lib/tcpdf.rb
test/functional/issues_controller_test.rb

index d754eb89152fda0a40827584a2435232a370feca..781fbcfc092e7011c61d2cbc0a12807329e715e6 100644 (file)
@@ -1,3 +1,5 @@
+# encoding: ascii-8bit
+
 #============================================================+
 # File name   : tcpdf.rb
 # Begin       : 2002-08-03
index 4acc9fdd65dde2d40a0e54b991502f41abb45173..2d855b2c0ce16690795a9fbcc22aa38b12746b4a 100644 (file)
@@ -1395,6 +1395,22 @@ class IssuesControllerTest < ActionController::TestCase
     assert_not_nil assigns(:issue)
   end
 
+  def test_export_to_pdf_with_utf8_u_fffd
+    # U+FFFD
+    s = "\xef\xbf\xbd"
+    s.force_encoding('UTF-8') if s.respond_to?(:force_encoding)
+    issue = Issue.generate!(:subject => s)
+    ["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
+      with_settings :default_language => lang do
+        get :show, :id => issue.id, :format => 'pdf'
+        assert_response :success
+        assert_equal 'application/pdf', @response.content_type
+        assert @response.body.starts_with?('%PDF')
+        assert_not_nil assigns(:issue)
+      end
+    end
+  end
+
   def test_show_export_to_pdf_with_ancestors
     issue = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)