Encoding::InvalidByteSequenceError may be raised even if encoding is valid (#12787).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11178 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-01-12 22:34:00 +00:00
parent ff53a9cfe1
commit 45f870cb53
1 changed files with 3 additions and 1 deletions

View 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