Brute force fix for Changeset#committer encoding on 1.9.2

This commit is contained in:
Eric Davis 2011-07-22 10:10:23 -07:00
parent 477a5f3702
commit d2724ef89c
1 changed files with 9 additions and 7 deletions

View File

@ -74,6 +74,14 @@ class Changeset < ActiveRecord::Base
user || committer.to_s.split('<').first
end
# Committer of the Changeset
#
# Attribute reader for committer that encodes the committer string to
# the repository log encoding (e.g. UTF-8)
def committer
self.class.to_utf8(read_attribute(:committer), repository.repo_log_encoding)
end
def before_create
self.committer = self.class.to_utf8(self.committer, repository.repo_log_encoding)
self.comments = self.class.normalize_comments(self.comments, repository.repo_log_encoding)
@ -273,12 +281,6 @@ class Changeset < ActiveRecord::Base
end
str = txtar
end
# removes invalid UTF8 sequences
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
str
end
end