Skip to content

Commit 0dd2404

Browse files
committed
Merge pull request rails#37494 from shugo/safe_buffer_enumerator_fix
Enumerator should be supported by ActiveSupport::SafeBuffer
1 parent 8297f8a commit 0dd2404

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

activesupport/lib/active_support/core_ext/string/output_safety.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ def html_escape_interpolated_argument(arg)
298298

299299
def set_block_back_references(block, match_data)
300300
block.binding.eval("proc { |m| $~ = m }").call(match_data)
301+
rescue ArgumentError
302+
# Can't create binding from C level Proc
301303
end
302304
end
303305
end

activesupport/test/safe_buffer_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,9 @@ def test_titleize
274274
assert_equal "123foo 456bar", b
275275
assert_not_predicate b, :html_safe?
276276
end
277+
278+
test "Should support Enumerator" do
279+
a = "aaa".html_safe.gsub!(/a/).with_index { |m, i| i }
280+
assert_equal "012", a
281+
end
277282
end

0 commit comments

Comments
 (0)