mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Enumerator should be supported by ActiveSupport::SafeBuffer
Back references cannot be set because C level Proc doesn't support Binding. This commit fixes #37422.
This commit is contained in:
parent
7fd5ca79a5
commit
dc87302cdf
2 changed files with 7 additions and 0 deletions
|
@ -297,6 +297,8 @@ module ActiveSupport #:nodoc:
|
|||
|
||||
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
|
||||
|
|
|
@ -274,4 +274,9 @@ class SafeBufferTest < ActiveSupport::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue