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

ruby-changes:37590

From: naruse <ko1@a...>
Date: Sat, 21 Feb 2015 12:47:42 +0900 (JST)
Subject: [ruby-changes:37590] naruse:r49671 (ruby_2_2): merge revision(s) 49618, 49640: [Backport #10858]

naruse	2015-02-21 12:47:36 +0900 (Sat, 21 Feb 2015)

  New Revision: 49671

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

  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_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/test/ruby/test_file_exhaustive.rb
    branches/ruby_2_2/version.h
    branches/ruby_2_2/win32/file.c
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 49670)
+++ ruby_2_2/ChangeLog	(revision 49671)
@@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Sat Feb 21 12:46:51 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]
+
+Sat Feb 21 12:46:51 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]
+
 Sat Feb 21 12:45:54 2015  Matt Hoyle  <matt@d...>
 
 	* ext/bigdecimal/bigdecimal.c (VpSetPTR): fix a typo, 'expoennt'
Index: ruby_2_2/win32/file.c
===================================================================
--- ruby_2_2/win32/file.c	(revision 49670)
+++ ruby_2_2/win32/file.c	(revision 49671)
@@ -398,6 +398,8 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_2/win32/file.c#L398
 	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'~') {
@@ -492,15 +494,11 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_2/win32/file.c#L494
 
     /* 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;
 	}
     }
 
@@ -531,6 +529,10 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_2/win32/file.c#L529
 	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_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 49670)
+++ ruby_2_2/version.h	(revision 49671)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.0"
 #define RUBY_RELEASE_DATE "2015-02-21"
-#define RUBY_PATCHLEVEL 71
+#define RUBY_PATCHLEVEL 72
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_2/test/ruby/test_file_exhaustive.rb
===================================================================
--- ruby_2_2/test/ruby/test_file_exhaustive.rb	(revision 49670)
+++ ruby_2_2/test/ruby/test_file_exhaustive.rb	(revision 49671)
@@ -447,6 +447,7 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/ruby_2_2/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'))
     when /darwin/
       ["\u{feff}", *"\u{2000}"..."\u{2100}"].each do |c|
@@ -795,6 +796,12 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_file_exhaustive.rb#L796
     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_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49618,49640


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

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