[前][次][番号順一覧][スレッド一覧]

ruby-changes:51598

From: usa <ko1@a...>
Date: Sat, 30 Jun 2018 22:24:28 +0900 (JST)
Subject: [ruby-changes:51598] usa:r63809 (ruby_2_4): Fix path checks for case insensitive filesystem

usa	2018-06-30 22:24:21 +0900 (Sat, 30 Jun 2018)

  New Revision: 63809

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63809

  Log:
    Fix path checks for case insensitive filesystem
    
    see https://github.com/rubygems/rubygems/pull/2211
    [ruby-core:86745] [Backport #14721]

  Modified files:
    branches/ruby_2_4/lib/rubygems/package.rb
    branches/ruby_2_4/lib/rubygems.rb
    branches/ruby_2_4/test/rubygems/test_gem_package.rb
    branches/ruby_2_4/version.h
Index: ruby_2_4/lib/rubygems/package.rb
===================================================================
--- ruby_2_4/lib/rubygems/package.rb	(revision 63808)
+++ ruby_2_4/lib/rubygems/package.rb	(revision 63809)
@@ -429,6 +429,14 @@ EOM https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/package.rb#L429
     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 https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/package.rb#L445
       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
Index: ruby_2_4/lib/rubygems.rb
===================================================================
--- ruby_2_4/lib/rubygems.rb	(revision 63808)
+++ ruby_2_4/lib/rubygems.rb	(revision 63809)
@@ -10,7 +10,7 @@ require 'rbconfig' https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems.rb#L10
 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
Index: ruby_2_4/test/rubygems/test_gem_package.rb
===================================================================
--- ruby_2_4/test/rubygems/test_gem_package.rb	(revision 63808)
+++ ruby_2_4/test/rubygems/test_gem_package.rb	(revision 63809)
@@ -524,6 +524,21 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/rubygems/test_gem_package.rb#L524
     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
 
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 63808)
+++ ruby_2_4/version.h	(revision 63809)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]