Skip to content

Commit

Permalink
Merge pull request #37494 from shugo/safe_buffer_enumerator_fix
Browse files Browse the repository at this point in the history
Enumerator should be supported by ActiveSupport::SafeBuffer
  • Loading branch information
kamipo committed Oct 17, 2019
2 parents cd619e9 + dc87302 commit c8d6a0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Expand Up @@ -297,6 +297,8 @@ def html_escape_interpolated_argument(arg)

def set_block_back_references(block, match_data)
block.binding.eval("proc { |m| $~ = m }").call(match_data)
rescue ArgumentError
# Can't create binding from C level Proc
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions activesupport/test/safe_buffer_test.rb
Expand Up @@ -274,4 +274,9 @@ def test_titleize
assert_equal "123foo 456bar", b
assert_not_predicate b, :html_safe?
end

test "Should support Enumerator" do
a = "aaa".html_safe.gsub!(/a/).with_index { |m, i| i }
assert_equal "012", a
end
end

0 comments on commit c8d6a0a

Please sign in to comment.