summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-04-12 05:03:59 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-04-12 05:03:59 +0000
commitbb48d96d3037c9ef909af310fc21ef19b7550d52 (patch)
tree48fa791a9cefa07b013a1b9f9a150e170442c1db /app
parent62952a9885072aec513e57193a6a0ff525b9adc8 (diff)
downloadredmine-bb48d96d3037c9ef909af310fc21ef19b7550d52.tar.gz
redmine-bb48d96d3037c9ef909af310fc21ef19b7550d52.zip
scm: replace invalid utf-8 sequences instead of stripping in displaying repository contents on Ruby 1.8.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5427 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/repositories_helper.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb
index 36cd90fba..c873e1ce6 100644
--- a/app/helpers/repositories_helper.rb
+++ b/app/helpers/repositories_helper.rb
@@ -156,12 +156,18 @@ module RepositoriesHelper
:undef => :replace, :replace => '?').encode("UTF-8")
end
else
- # removes invalid UTF8 sequences
+ ic = Iconv.new('UTF-8', 'UTF-8')
+ txtar = ""
begin
- str = Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3]
- rescue Iconv::InvalidEncoding
- # "UTF-8//IGNORE" is not supported on some OS
+ txtar += ic.iconv(str)
+ rescue Iconv::IllegalSequence
+ txtar += $!.success
+ str = '?' + $!.failed[1,$!.failed.length]
+ retry
+ rescue
+ txtar += $!.success
end
+ str = txtar
end
str
end