ruby-changes:61897
From: Kazuhiro <ko1@a...>
Date: Mon, 22 Jun 2020 18:35:27 +0900 (JST)
Subject: [ruby-changes:61897] 6adbdb56ed (master): Fix Encoding::CompatibilityError in `FileUtils::Entry_#join`
https://git.ruby-lang.org/ruby.git/commit/?id=6adbdb56ed From 6adbdb56edcf62c11229e1c9c6f75656700f1c5f Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA <zn@m...> Date: Mon, 22 Jun 2020 18:34:24 +0900 Subject: Fix Encoding::CompatibilityError in `FileUtils::Entry_#join` diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 438f321..c8f4b49 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -1557,7 +1557,15 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1557 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 diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index 274492d..8a546cc 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -771,9 +771,6 @@ class TestFileUtils < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L771 remove_entry dir assert_file_not_exist dir - rescue MiniTest::Assertion - STDERR.puts Dir.glob("#{dir}/**/*").inspect - raise end def test_remove_entry_secure -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/