summaryrefslogtreecommitdiffstats
path: root/app/models/changeset.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/changeset.rb')
-rw-r--r--app/models/changeset.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 804719481..ca4daace8 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -227,7 +227,13 @@ class Changeset < ActiveRecord::Base
end
def self.to_utf8(str)
- return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
+ 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
+
encoding = Setting.commit_logs_encoding.to_s.strip
unless encoding.blank? || encoding == 'UTF-8'
begin