From: Jean-Philippe Lang Date: Sun, 20 Mar 2011 11:14:50 +0000 (+0000) Subject: Fixes RepositoriesHelper#to_utf8 test failure for ruby1.8. X-Git-Tag: 1.2.0~674 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2201a343e40d5e22f94b18909cb06ce4b3076c18;p=redmine.git Fixes RepositoriesHelper#to_utf8 test failure for ruby1.8. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5169 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index fa58f5d55..0dc450b36 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -154,6 +154,13 @@ module RepositoriesHelper str = str.encode("US-ASCII", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8") end + else + # removes invalid UTF8 sequences + begin + str = Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3] + rescue Iconv::InvalidEncoding + # "UTF-8//IGNORE" is not supported on some OS + end end str end