diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 9037b39f1..fb1d4dd05 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require 'iconv' +require 'redmine/codeset_util' module RepositoriesHelper def format_revision(revision) @@ -143,35 +144,10 @@ module RepositoriesHelper # do nothing here and try the next encoding end end - str = replace_invalid_utf8(str) + str = Redmine::CodesetUtil.replace_invalid_utf8(str) end private :to_utf8_internal - def replace_invalid_utf8(str) - return str if str.nil? - if str.respond_to?(:force_encoding) - str.force_encoding('UTF-8') - if ! str.valid_encoding? - str = str.encode("US-ASCII", :invalid => :replace, - :undef => :replace, :replace => '?').encode("UTF-8") - end - else - ic = Iconv.new('UTF-8', 'UTF-8') - txtar = "" - begin - txtar += ic.iconv(str) - rescue Iconv::IllegalSequence - txtar += $!.success - str = '?' + $!.failed[1,$!.failed.length] - retry - rescue - txtar += $!.success - end - str = txtar - end - str - end - def repository_field_tags(form, repository) method = repository.class.name.demodulize.underscore + "_field_tags" if repository.is_a?(Repository) && diff --git a/app/views/repositories/_dir_list_content.rhtml b/app/views/repositories/_dir_list_content.rhtml index fd9dd7afc..a4e08b046 100644 --- a/app/views/repositories/_dir_list_content.rhtml +++ b/app/views/repositories/_dir_list_content.rhtml @@ -1,8 +1,8 @@ <% @entries.each do |entry| %> <% tr_id = Digest::MD5.hexdigest(entry.path) depth = params[:depth].to_i %> -<% ent_path = replace_invalid_utf8(entry.path) %> -<% ent_name = replace_invalid_utf8(entry.name) %> +<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path) %> +<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %>