Index: lib/redmine/codeset_util.rb =================================================================== --- lib/redmine/codeset_util.rb (revision 16111) +++ lib/redmine/codeset_util.rb (working copy) @@ -6,8 +6,8 @@ return str if str.nil? str.force_encoding('UTF-8') if ! str.valid_encoding? - str = str.encode("US-ASCII", :invalid => :replace, - :undef => :replace, :replace => '?').encode("UTF-8") + str = str.encode("UTF-8", :invalid => :replace, + :undef => :replace, :replace => '?') end str end @@ -27,8 +27,8 @@ else str.force_encoding("UTF-8") if ! str.valid_encoding? - str = str.encode("US-ASCII", :invalid => :replace, - :undef => :replace, :replace => '?').encode("UTF-8") + str = str.encode("UTF-8", :invalid => :replace, + :undef => :replace, :replace => '?') end end str Index: test/unit/mail_handler_test.rb =================================================================== --- test/unit/mail_handler_test.rb (revision 16111) +++ test/unit/mail_handler_test.rb (working copy) @@ -538,6 +538,16 @@ assert_equal 'd8e8fca2dc0f896fd7cb4cb0031ba249', attachment.digest end + def test_invalid_utf8 + issue = submit_email( + 'invalid_utf8.eml', + :issue => {:project => 'ecookbook'} + ) + assert_kind_of Issue, issue + description = "\xD0\x97\xD0\xB4\xD1\x80\xD0\xB0\xD0\xB2\xD1\x81\xD1\x82\xD0\xB2\xD1\x83\xD0\xB9\xD1\x82\xD0\xB5?".force_encoding('UTF-8') + assert_equal description, issue.description + end + def test_gmail_with_attachment_ja issue = submit_email( 'gmail_with_attachment_ja.eml',