-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Description
commit 53a2c0b introduced a change to ensure gsub returns an unsafe string.
When gsub is used in block form, variables such as $1,
This is the simplest test I can make to demonstrate the issue (which currently fails on 3.0-stable)...
class SafeBufferTest < ActiveSupport::TestCase
def setup
@buffer = ActiveSupport::SafeBuffer.new
end
[..]
test "Should not break gsub block form match variables" do
@buffer << 'matchme'
@buffer.gsub(/(matchme)/) { assert_equal 'matchme', $1 }
end
So far it's know that this breaks escape_javascript since it uses $1 matcher (see #1553 ). I presume there may be others also affected.
Investigating what a good fix would be.. seems awful heavy handed to have to capture and reset all those variables, but on the other hand, its bad form to leave a ruby core method different from it's documented behaviour.