diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-01-01 13:40:36 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-01-01 13:40:36 +0000 |
commit | 488285e12321fc590dee0235470cfb12d77a3432 (patch) | |
tree | d8f44a7dad87372748a64e12cedf66148c0e85f9 /app/helpers/attachments_helper.rb | |
parent | 1c7079db3fb099c6913353c9d56c27628b712026 (diff) | |
download | redmine-488285e12321fc590dee0235470cfb12d77a3432.tar.gz redmine-488285e12321fc590dee0235470cfb12d77a3432.zip |
Strip non utf8 content when displaying diff (ruby1.9 compatibility).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4604 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/attachments_helper.rb')
-rw-r--r-- | app/helpers/attachments_helper.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 29cdb9790..50b44890f 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -29,6 +29,12 @@ module AttachmentsHelper end def to_utf8(str) - str + return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii + begin + Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3] + rescue Iconv::InvalidEncoding + # "UTF-8//IGNORE" is not supported on some OS + str + end end end |