diff options
author | Aaron Patterson <tenderlove@github.com> | 2018-09-06 15:00:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-06 15:00:05 -0700 |
commit | b31ae3131a488aca3aac556f8f3ba26499c564e6 (patch) | |
tree | c94d1d8e53114ebde5a6e72339380b694c966447 /activesupport/test/safe_buffer_test.rb | |
parent | 7fc545365cd219164e361b8e12b0995ca339477e (diff) | |
parent | 1d42a661d8ff7795ebf9255cb7efd17de7b47fb0 (diff) | |
download | rails-b31ae3131a488aca3aac556f8f3ba26499c564e6.tar.gz rails-b31ae3131a488aca3aac556f8f3ba26499c564e6.tar.bz2 rails-b31ae3131a488aca3aac556f8f3ba26499c564e6.zip |
Merge pull request #33808 from itsbagpack/fix-access-safety-buffer-slice
Maintain html_safe? on sliced HTML safe strings
Diffstat (limited to 'activesupport/test/safe_buffer_test.rb')
-rw-r--r-- | activesupport/test/safe_buffer_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb index 9456bb8753..70dec6b3d2 100644 --- a/activesupport/test/safe_buffer_test.rb +++ b/activesupport/test/safe_buffer_test.rb @@ -150,6 +150,18 @@ class SafeBufferTest < ActiveSupport::TestCase assert_not y.html_safe?, "should not be safe" end + test "Should continue safe on slice" do + x = "<div>foo</div>".html_safe + + assert_predicate x, :html_safe? + + # getting a slice of it + y = x[0..-1] + + # should still be safe + assert_predicate y, :html_safe? + end + test "Should work with interpolation (array argument)" do x = "foo %s bar".html_safe % ["qux"] assert_equal "foo qux bar", x |