1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix Encoding::CompatibilityError in FileUtils::Entry_#join

This commit is contained in:
Kazuhiro NISHIYAMA 2020-06-22 18:34:24 +09:00
parent 3a1e63e540
commit 6adbdb56ed
No known key found for this signature in database
GPG key ID: 262ED8DBB4222F7A
2 changed files with 9 additions and 4 deletions

View file

@ -1557,7 +1557,15 @@ module FileUtils
def join(dir, base)
return File.path(dir) if not base or base == '.'
return File.path(base) if not dir or dir == '.'
File.join(dir, base)
begin
File.join(dir, base)
rescue EncodingError
if fu_windows?
File.join(dir.encode(::Encoding::UTF_8), base.encode(::Encoding::UTF_8))
else
raise
end
end
end
if File::ALT_SEPARATOR

View file

@ -771,9 +771,6 @@ class TestFileUtils < Test::Unit::TestCase
remove_entry dir
assert_file_not_exist dir
rescue MiniTest::Assertion
STDERR.puts Dir.glob("#{dir}/**/*").inspect
raise
end
def test_remove_entry_secure