diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index baa43660c5c028130f15718ae3356ed4efc91c24..89a17195b86fa9806c57c3cac9603ab0689f96d9 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
diff --git a/test/fixtures/encoding/iso-8859-1.txt b/test/fixtures/encoding/iso-8859-1.txt
new file mode 100644
index 0000000000000000000000000000000000000000..8ad6cc0f21495fd4fd6808750542e43ffc57c38a
--- /dev/null
+++ b/test/fixtures/encoding/iso-8859-1.txt
@@ -0,0 +1 @@
+Texte encodé en ISO-8859-1.
\ No newline at end of file
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb
index 8d57c43abbd56c9d169e5f541b2e00bf27bc88a3..8010383feab5c037c95e9517fa439f597ba1719f 100644
--- a/test/unit/changeset_test.rb
+++ b/test/unit/changeset_test.rb
@@ -1,5 +1,7 @@
-# redMine - project management software
-# Copyright (C) 2006-2007  Jean-Philippe Lang
+# encoding: utf-8
+#
+# Redmine - project management software
+# 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
@@ -117,4 +119,18 @@ class ChangesetTest < ActiveSupport::TestCase
     changeset = Changeset.find_by_revision('10')
     assert_nil changeset.next
   end
+  
+  def test_comments_should_be_converted_to_utf8
+    with_settings :commit_logs_encoding => 'ISO-8859-1' do
+      c = Changeset.new
+      c.comments = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
+      assert_equal "Texte encodé en ISO-8859-1.", c.comments
+    end
+  end
+  
+  def test_invalid_utf8_sequences_in_comments_should_be_stripped
+    c = Changeset.new
+    c.comments = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
+    assert_equal "Texte encod en ISO-8859-1.", c.comments
+  end
 end