diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-03-08 16:28:19 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-03-08 16:28:19 +0000 |
commit | a5b18b631ceb31c4c0fc7b0bec1ebdb0285e762a (patch) | |
tree | 7c19eb536894bec065b4202d95a695de5f31d0f4 /app/models | |
parent | f2d9af6dc32a67223e024c2acafce29355c9414c (diff) | |
download | redmine-a5b18b631ceb31c4c0fc7b0bec1ebdb0285e762a.tar.gz redmine-a5b18b631ceb31c4c0fc7b0bec1ebdb0285e762a.zip |
Make sure that strings of serialized settings are UTF-8 encoded (#19305).
git-svn-id: http://svn.redmine.org/redmine/trunk@14067 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/setting.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/app/models/setting.rb b/app/models/setting.rb index ca280ebcd..cc4131bec 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -91,7 +91,10 @@ class Setting < ActiveRecord::Base def value v = read_attribute(:value) # Unserialize serialized settings - v = YAML::load(v) if available_settings[name]['serialized'] && v.is_a?(String) + if available_settings[name]['serialized'] && v.is_a?(String) + v = YAML::load(v) + force_utf8_strings(v) + end v = v.to_sym if available_settings[name]['format'] == 'symbol' && !v.blank? v end @@ -238,6 +241,23 @@ END_SRC load_plugin_settings private + + def force_utf8_strings(arg) + if arg.is_a?(String) + arg.force_encoding('UTF-8') + elsif arg.is_a?(Array) + arg.each do |a| + force_utf8_strings(a) + end + elsif arg.is_a?(Hash) + arg.each do |k,v| + force_utf8_strings(k) + force_utf8_strings(v) + end + end + arg + end + # Returns the Setting instance for the setting named name # (record found in database or new record with default value) def self.find_or_default(name) |