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

ruby-changes:38588

From: usa <ko1@a...>
Date: Fri, 29 May 2015 14:01:22 +0900 (JST)
Subject: [ruby-changes:38588] usa:r50669 (ruby_2_1): merge revision(s) 49618, 49640: [Backport #10858]

usa	2015-05-29 14:01:04 +0900 (Fri, 29 May 2015)

  New Revision: 50669

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

  Log:
    merge revision(s) 49618,49640: [Backport #10858]
    
    * win32/file.c (rb_file_expand_path_internal): do not make invalid
      (or ADS) path if the path has a drive letter, the result also
      should have be under it.  [ruby-core:68130] [Bug #10858]
    
    * win32/file.c (rb_file_expand_path_internal): neither the drive
      of base directory nor the current drive are involved in the
      result if different than the drive of path.
      [ruby-core:68130] [Bug #10858]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/test/ruby/test_file_exhaustive.rb
    branches/ruby_2_1/version.h
    branches/ruby_2_1/win32/file.c
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 50668)
+++ ruby_2_1/ChangeLog	(revision 50669)
@@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Fri May 29 14:00:16 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/file.c (rb_file_expand_path_internal): neither the drive
+	  of base directory nor the current drive are involved in the
+	  result if different than the drive of path.
+	  [ruby-core:68130] [Bug #10858]
+
+Fri May 29 14:00:16 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/file.c (rb_file_expand_path_internal): do not make invalid
+	  (or ADS) path if the path has a drive letter, the result also
+	  should have be under it.  [ruby-core:68130] [Bug #10858]
+
 Fri May 29 13:41:44 2015  NAKAMURA Usaku  <usa@r...>
 
 	* marshal.c (r_symreal): register the symbol name first so that
Index: ruby_2_1/win32/file.c
===================================================================
--- ruby_2_1/win32/file.c	(revision 50668)
+++ ruby_2_1/win32/file.c	(revision 50669)
@@ -415,6 +415,8 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_1/win32/file.c#L415
 	else {
 	    /* determine if we ignore dir or not later */
 	    path_drive = wpath_pos[0];
+	    wpath_pos += 2;
+	    wpath_len -= 2;
 	}
     }
     else if (abs_mode == 0 && wpath_len >= 2 && wpath_pos[0] == L'~') {
@@ -505,15 +507,11 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_1/win32/file.c#L507
 
     /* determine if we ignore dir or not */
     if (!ignore_dir && path_drive && dir_drive) {
-	if (towupper(path_drive) == towupper(dir_drive)) {
-	    /* exclude path drive letter to use dir */
-	    wpath_pos += 2;
-	    wpath_len -= 2;
-	}
-	else {
+	if (towupper(path_drive) != towupper(dir_drive)) {
 	    /* ignore dir since path drive is different from dir drive */
 	    ignore_dir = 1;
 	    wdir_len = 0;
+	    dir_drive = 0;
 	}
     }
 
@@ -544,6 +542,10 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_1/win32/file.c#L542
 	buffer_pos[0] = L'\\';
 	buffer_pos++;
     }
+    else if (!dir_drive && path_drive) {
+	*buffer_pos++ = path_drive;
+	*buffer_pos++ = L':';
+    }
 
     if (wdir_len) {
 	/* tainted if dir is used and dir is tainted */
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 50668)
+++ ruby_2_1/version.h	(revision 50669)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.7"
 #define RUBY_RELEASE_DATE "2015-05-29"
-#define RUBY_PATCHLEVEL 360
+#define RUBY_PATCHLEVEL 361
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 5
Index: ruby_2_1/test/ruby/test_file_exhaustive.rb
===================================================================
--- ruby_2_1/test/ruby/test_file_exhaustive.rb	(revision 50668)
+++ ruby_2_1/test/ruby/test_file_exhaustive.rb	(revision 50669)
@@ -447,6 +447,7 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_file_exhaustive.rb#L447
       assert_equal(@file, File.expand_path(@file + "::$DATA"))
       assert_match(/\Ac:\//i, File.expand_path('c:'), '[ruby-core:31591]')
       assert_match(/\Ac:\//i, File.expand_path('c:foo', 'd:/bar'))
+      assert_match(/\Ae:\//i, File.expand_path('e:foo', 'd:/bar'))
       assert_match(%r'\Ac:/bar/foo\z'i, File.expand_path('c:foo', 'c:/bar'))
     end
     if DRIVE
@@ -784,6 +785,12 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_file_exhaustive.rb#L785
     assert_equal("#{Dir.pwd}/a/b/c", File.expand_path(obj))
   end
 
+  def test_expand_path_with_drive_letter
+    bug10858 = '[ruby-core:68130] [Bug #10858]'
+    assert_match(%r'/bar/foo\z'i, File.expand_path('z:foo', 'bar'), bug10858)
+    assert_equal('z:/bar/foo', File.expand_path('z:foo', '/bar'), bug10858)
+  end if DRIVE
+
   def test_basename
     assert_equal(File.basename(@file).sub(/\.test$/, ""), File.basename(@file, ".test"))
     assert_equal("", s = File.basename(""))

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49618,49640


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

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