diff options
author | Vasiliy Ermolovich <younash@gmail.com> | 2012-05-16 21:04:31 +0300 |
---|---|---|
committer | Vasiliy Ermolovich <younash@gmail.com> | 2012-05-16 21:05:26 +0300 |
commit | 9fb21e98e2a3c8c19dce8a2c4bb8a850af65a054 (patch) | |
tree | 5169240dca52d916d392fbfc5ebebc5f9312f69c /activesupport/lib | |
parent | e29626901ad82bafeb7ade13c3681aa777d7fe2a (diff) | |
download | rails-9fb21e98e2a3c8c19dce8a2c4bb8a850af65a054.tar.gz rails-9fb21e98e2a3c8c19dce8a2c4bb8a850af65a054.tar.bz2 rails-9fb21e98e2a3c8c19dce8a2c4bb8a850af65a054.zip |
fix safe string interpolation with SafeBuffer#%, closes #6352
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/output_safety.rb | 14 |
1 files changed, 14 insertions, 0 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 6bda970e40..f98d5b3777 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -150,6 +150,20 @@ module ActiveSupport #:nodoc: dup.concat(other) end + def %(args) + args = Array(args) + + args.map! do |arg| + if !html_safe? || arg.html_safe? + arg + else + ERB::Util.h(arg) + end + end + + self.class.new(super(args)) + end + def html_safe? defined?(@html_safe) && @html_safe end |