]> source.dussan.org Git - redmine.git/commitdiff
Force encoding of custom field possible values (#10593).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 6 Apr 2012 07:39:50 +0000 (07:39 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 6 Apr 2012 07:39:50 +0000 (07:39 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9330 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/custom_field.rb

index 02736aea29f132f07d1692a4f1b2234039793ae2..75fac24642009b69f32c39403cdbb8a635517d77 100644 (file)
@@ -80,7 +80,7 @@ class CustomField < ActiveRecord::Base
     when 'bool'
       [[l(:general_text_Yes), '1'], [l(:general_text_No), '0']]
     else
-      read_attribute(:possible_values) || []
+      read_possible_values_utf8_encoded || []
     end
   end
 
@@ -91,7 +91,7 @@ class CustomField < ActiveRecord::Base
     when 'bool'
       ['1', '0']
     else
-      read_attribute :possible_values
+      read_possible_values_utf8_encoded
     end
   end
 
@@ -218,4 +218,14 @@ class CustomField < ActiveRecord::Base
     end
     errs
   end
+
+  def read_possible_values_utf8_encoded
+    values = read_attribute(:possible_values)
+    if values.is_a?(Array)
+      values.each do |value|
+        value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
+      end
+    end
+    values
+  end
 end