]> source.dussan.org Git - redmine.git/commitdiff
Make sure that #scm_iconv returns a string with the target encoding (#14534).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 18 Jan 2015 16:16:23 +0000 (16:16 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 18 Jan 2015 16:16:23 +0000 (16:16 +0000)
filechanges.find_by_revision_and_path fails with SQLite if arguments are not UTF-8 encoded.

git-svn-id: http://svn.redmine.org/redmine/trunk@13902 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/scm/adapters/abstract_adapter.rb
test/unit/repository_cvs_test.rb

index 1d10abb163667f29a38cd9db027860adea3c2644..98683b0158069f5f74883ff0ea110991d8c70a08 100644 (file)
@@ -283,7 +283,7 @@ module Redmine
 
         def scm_iconv(to, from, str)
           return nil if str.nil?
-          return str if to == from
+          return str if to == from && str.encoding.to_s == from
           str.force_encoding(from)
           begin
             str.encode(to)
index fc5bbb8a184fd4d706a0c33b72adc8ea25f020c7..04d086306e5bc54a863532734b6f01f92e2bc075 100644 (file)
@@ -179,6 +179,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
       assert_kind_of Redmine::Scm::Adapters::Entries, entries
       assert_equal 3, entries.size
       assert_equal entries[2].name, "README"
+      assert_equal 'UTF-8', entries[2].path.encoding.to_s
       assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22)
       assert_equal entries[2].lastrev.identifier, '3'
       assert_equal entries[2].lastrev.revision, '3'