summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-30 13:24:21 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-30 13:24:21 +0000
commitc0e77089b2f3c5358562d2fe58e74cc91f8813da (patch)
treea811d42a9fd5235d72e38466969d54a2da6ed1ed
parent9796be14ac1bf0af31861f995d35d9740a01aad1 (diff)
Fix path checks for case insensitive filesystem
see https://github.com/rubygems/rubygems/pull/2211 [ruby-core:86745] [Backport #14721] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@63809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/package.rb10
-rw-r--r--test/rubygems/test_gem_package.rb15
-rw-r--r--version.h2
4 files changed, 26 insertions, 3 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 53be979a52..4ab0da9acf 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -10,7 +10,7 @@ require 'rbconfig'
require 'thread'
module Gem
- VERSION = "2.6.14.2"
+ VERSION = "2.6.14.3"
end
# Must be first since it unloads the prelude from 1.9.2
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index b5a5fe2a26..1dd28d8132 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -429,6 +429,14 @@ EOM
destination
end
+ def normalize_path(pathname)
+ if Gem.win_platform?
+ pathname.downcase
+ else
+ pathname
+ end
+ end
+
def mkdir_p_safe mkdir, mkdir_options, destination_dir, file_name
destination_dir = realpath File.expand_path(destination_dir)
parts = mkdir.split(File::SEPARATOR)
@@ -437,7 +445,7 @@ EOM
path = File.expand_path(path + File::SEPARATOR + basename)
lstat = File.lstat path rescue nil
if !lstat || !lstat.directory?
- unless path.start_with? destination_dir and (FileUtils.mkdir path, mkdir_options rescue false)
+ unless normalize_path(path).start_with? normalize_path(destination_dir) and (FileUtils.mkdir path, mkdir_options rescue false)
raise Gem::Package::PathError.new(file_name, destination_dir)
end
end
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb
index 5b93475314..713c84d700 100644
--- a/test/rubygems/test_gem_package.rb
+++ b/test/rubygems/test_gem_package.rb
@@ -524,6 +524,21 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_path_exists extracted
end
+ if Gem.win_platform?
+ def test_extract_tar_gz_case_insensitive
+ package = Gem::Package.new @gem
+
+ tgz_io = util_tar_gz do |tar|
+ tar.add_file 'foo/file.rb', 0644 do |io| io.write 'hi' end
+ end
+
+ package.extract_tar_gz tgz_io, @destination.upcase
+
+ extracted = File.join @destination, 'foo/file.rb'
+ assert_path_exists extracted
+ end
+ end
+
def test_install_location
package = Gem::Package.new @gem
diff --git a/version.h b/version.h
index a53efaadcc..30f27d5083 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.5"
#define RUBY_RELEASE_DATE "2018-06-30"
-#define RUBY_PATCHLEVEL 304
+#define RUBY_PATCHLEVEL 305
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 6