aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-05-07 11:41:12 +0100
committerLouise Crow <louise.crow@gmail.com>2015-05-07 12:17:12 +0100
commit824771a4fb7846bec13e395e44f14718ff30d17d (patch)
treed565f6c430c126a56f1bb889383c7199d11a0c17 /app/models
parent751bd3df3b6b28275e0ac9f6b1663c1df84d007f (diff)
Force the encoding of values returned from YAML.
This is a workaround for an issue where YAML in ruby 1.8 tags UTF-8 heavy strings as binary, resulting in them being retrieved under 1.9 as ASCII-8BIT which can't be concatenated with UTF-8. Described as "Deep deep YAML oddness" in https://www.zendesk.com/blog/upgrade-the-road-to-1-9/.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/info_request_event.rb8
-rw-r--r--app/models/post_redirect.rb6
2 files changed, 12 insertions, 2 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 9dde3ba80..8a113cbf8 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -279,9 +279,15 @@ class InfoRequestEvent < ActiveRecord::Base
end
self.params_yaml = params.to_yaml
end
+
def params
- YAML.load(self.params_yaml)
+ param_hash = YAML.load(params_yaml)
+ param_hash.each do |key, value|
+ param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
+ end
+ param_hash
end
+
def params_yaml_as_html
ret = ''
# split out parameters into old/new diffs, and other ones
diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb
index 8049349d0..59160381c 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -71,7 +71,11 @@ class PostRedirect < ActiveRecord::Base
end
def reason_params
- YAML.load(reason_params_yaml)
+ param_hash = YAML.load(reason_params_yaml)
+ param_hash.each do |key, value|
+ param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
+ end
+ param_hash
end
# Extract just local path part, without domain or #