зеркало из https://github.com/github/ruby.git
Correctly remove temporary directory if path yielded is mutated
Another approach would be to freeze the string, but that could cause backwards compatibility issues. Fixes [Bug #16918]
This commit is contained in:
Родитель
0bd025ad69
Коммит
2ecfb88ee5
|
@ -86,7 +86,7 @@ class Dir
|
|||
}
|
||||
if block_given?
|
||||
begin
|
||||
yield path
|
||||
yield path.dup
|
||||
ensure
|
||||
unless base
|
||||
stat = File.stat(File.dirname(path))
|
||||
|
|
|
@ -52,6 +52,17 @@ class TestTmpdir < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_mktmpdir_mutate
|
||||
bug16918 = '[ruby-core:98563]'
|
||||
assert_nothing_raised(bug16918) do
|
||||
assert_mktmpdir_traversal do |traversal_path|
|
||||
Dir.mktmpdir(traversal_path + 'foo') do |actual|
|
||||
actual << "foo"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_mktmpdir_traversal
|
||||
assert_mktmpdir_traversal do |traversal_path|
|
||||
Dir.mktmpdir(traversal_path + 'foo') do |actual|
|
||||
|
|
Загрузка…
Ссылка в новой задаче