aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-12-29 12:56:01 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-12-29 12:56:01 -0300
commit54ec0cbf8276c63215fcb4507581003bbcd1a48d (patch)
tree514bccd4729e0d76fcb8fc9f7277ea8cda8a2152
parent724707edfdedc63672284be2887484e8b65da02e (diff)
downloadrails-54ec0cbf8276c63215fcb4507581003bbcd1a48d.tar.gz
rails-54ec0cbf8276c63215fcb4507581003bbcd1a48d.tar.bz2
rails-54ec0cbf8276c63215fcb4507581003bbcd1a48d.zip
Just check if the buffer exists before changing it
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb4
-rw-r--r--activesupport/test/safe_buffer_test.rb6
2 files changed, 4 insertions, 6 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 24d0f9319f..231eaedbba 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -150,9 +150,11 @@ module ActiveSupport #:nodoc:
else
if html_safe?
new_safe_buffer = super
- unless new_safe_buffer.respond_to?(:frozen?) && new_safe_buffer.frozen?
+
+ if new_safe_buffer
new_safe_buffer.instance_variable_set :@html_safe, true
end
+
new_safe_buffer
else
to_str[*args]
diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb
index fca4b45276..4532152996 100644
--- a/activesupport/test/safe_buffer_test.rb
+++ b/activesupport/test/safe_buffer_test.rb
@@ -168,10 +168,6 @@ class SafeBufferTest < ActiveSupport::TestCase
test 'Should not affect frozen objects when accessing characters' do
x = 'Hello'.html_safe
- assert_nothing_raised do
- x[/a/, 1]
- end
+ assert_equal x[/a/, 1], nil
end
-
-
end