aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2013-12-16 06:54:48 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2013-12-16 06:54:48 -0800
commite7b8769cbc821f07f1bd3505999da8d610bed538 (patch)
tree38c155f29c785a62940835445e0dce03a3224dac /activesupport/lib/active_support/core_ext
parent4b4aeabb3605bd0cbd7dde10c1d2ac990c65379a (diff)
parenta764938ad0ddb0aa73bb86215626f24b980e3f55 (diff)
downloadrails-e7b8769cbc821f07f1bd3505999da8d610bed538.tar.gz
rails-e7b8769cbc821f07f1bd3505999da8d610bed538.tar.bz2
rails-e7b8769cbc821f07f1bd3505999da8d610bed538.zip
Merge pull request #13321 from mezis/fix-safebuffer-interpolation-master
Fixes interpolation on SafeBuffer
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index 1b2098fc84..1b20507c0b 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -183,15 +183,14 @@ module ActiveSupport #:nodoc:
end
def %(args)
- args = Array(args).map do |arg|
- if !html_safe? || arg.html_safe?
- arg
- else
- ERB::Util.h(arg)
- end
+ case args
+ when Hash
+ escaped_args = Hash[args.map { |k,arg| [k, html_escape_interpolated_argument(arg)] }]
+ else
+ escaped_args = Array(args).map { |arg| html_escape_interpolated_argument(arg) }
end
- self.class.new(super(args))
+ self.class.new(super(escaped_args))
end
def html_safe?
@@ -224,6 +223,12 @@ module ActiveSupport #:nodoc:
EOT
end
end
+
+ private
+
+ def html_escape_interpolated_argument(arg)
+ (!html_safe? || arg.html_safe?) ? arg : ERB::Util.h(arg)
+ end
end
end