From 2201a343e40d5e22f94b18909cb06ce4b3076c18 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 20 Mar 2011 11:14:50 +0000 Subject: [PATCH] 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 --- app/helpers/repositories_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) 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