]> source.dussan.org Git - redmine.git/commitdiff
fix test failures (#12787)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sun, 13 Jan 2013 00:43:24 +0000 (00:43 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sun, 13 Jan 2013 00:43:24 +0000 (00:43 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11179 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/codeset_util.rb

index 33fe88bd753b34f7cdb90ec27f8f302f209b2ff5..45a5c352413a374a39227c624bfb4568e16e21b8 100644 (file)
@@ -103,10 +103,11 @@ module Redmine
       encodings = Setting.repositories_encodings.split(',').collect(&:strip)
       encodings.each do |encoding|
         if str.respond_to?(:force_encoding)
-          str.force_encoding(encoding)
           begin
-            return str.encode('UTF-8')
-          rescue Encoding::InvalidByteSequenceError
+            str.force_encoding(encoding)
+            utf8 = str.encode('UTF-8')
+            return utf8 if utf8.valid_encoding?
+          rescue
             # do nothing here and try the next encoding
           end
         else