From 77710ece26d8503e365a5211b010eb9be81c1c99 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sun, 20 Nov 2011 11:46:52 +0000 Subject: attachment: use repositories setting to convert contents character encoding (#2371) This commit results replacing invalid encoding instead to stripping. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7866 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/attachments_helper.rb | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'app/helpers/attachments_helper.rb') diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 640a40c21..3d98b95d3 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -29,19 +29,7 @@ module AttachmentsHelper end def to_utf8(str) - if str.respond_to?(:force_encoding) - str.force_encoding('UTF-8') - return str if str.valid_encoding? - else - return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii - end - - 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 + Redmine::CodesetUtil.to_utf8_by_setting(str) end def render_api_attachment(attachment, api) -- cgit v1.2.3