diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-02-20 11:24:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-02-20 11:24:41 +0000 |
commit | 46aa855572a26a1b0fab211e4ec79453ac8790fc (patch) | |
tree | ece0c59a51d34c5306cbdcbd250a4e1352de5f40 /app/models/changeset.rb | |
parent | 6e689215908185642990dc9bf010b627f06e6124 (diff) | |
download | redmine-46aa855572a26a1b0fab211e4ec79453ac8790fc.tar.gz redmine-46aa855572a26a1b0fab211e4ec79453ac8790fc.zip |
Remove invalid utf8 sequences from commit comments and author name (#4773).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3466 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/changeset.rb')
-rw-r--r-- | app/models/changeset.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb index baa43660c..89a17195b 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2008 Jean-Philippe Lang +# Copyright (C) 2006-2010 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -57,6 +57,10 @@ class Changeset < ActiveRecord::Base super end + def committer=(arg) + write_attribute(:committer, self.class.to_utf8(arg.to_s)) + end + def project repository.project end @@ -180,11 +184,12 @@ class Changeset < ActiveRecord::Base encoding = Setting.commit_logs_encoding.to_s.strip unless encoding.blank? || encoding == 'UTF-8' begin - return Iconv.conv('UTF-8', encoding, str) + str = Iconv.conv('UTF-8', encoding, str) rescue Iconv::Failure # do nothing here end end - str + # removes invalid UTF8 sequences + Iconv.conv('UTF-8//IGNORE', 'UTF-8', str + ' ')[0..-3] end end |