]> source.dussan.org Git - redmine.git/commitdiff
Encoding::InvalidByteSequenceError may be raised even if encoding is valid (#12787).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 Jan 2013 22:34:00 +0000 (22:34 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 Jan 2013 22:34:00 +0000 (22:34 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11178 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/codeset_util.rb

index 41ea851536b5fe1ff2fc3eef3e56058442019b47..33fe88bd753b34f7cdb90ec27f8f302f209b2ff5 100644 (file)
@@ -104,8 +104,10 @@ module Redmine
       encodings.each do |encoding|
         if str.respond_to?(:force_encoding)
           str.force_encoding(encoding)
-          if str.valid_encoding?
+          begin
             return str.encode('UTF-8')
+          rescue Encoding::InvalidByteSequenceError
+            # do nothing here and try the next encoding
           end
         else
           begin