]> source.dussan.org Git - redmine.git/commitdiff
Fixes RepositoriesHelper#to_utf8 test failure for ruby1.8.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Mar 2011 11:14:50 +0000 (11:14 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Mar 2011 11:14:50 +0000 (11:14 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5169 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/repositories_helper.rb

index fa58f5d55333c757286bff2195bb0b407fd8cb9f..0dc450b36a02901d002140c999fc5d3001ebc86a 100644 (file)
@@ -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