From 54ec0cbf8276c63215fcb4507581003bbcd1a48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 29 Dec 2014 12:56:01 -0300 Subject: Just check if the buffer exists before changing it --- activesupport/lib/active_support/core_ext/string/output_safety.rb | 4 +++- activesupport/test/safe_buffer_test.rb | 6 +----- 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 -- cgit v1.2.3