summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 05:01:04 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 05:01:04 +0000
commit6f97605fe308a98855f964e03a5faddde3ed5867 (patch)
tree786587cf8d34002cb7bc05ed6b3cccedde456640
parente8dc702f5e725fe6b168e1a5702a9443fbf88f4d (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog13
-rw-r--r--test/ruby/test_file_exhaustive.rb7
-rw-r--r--version.h2
-rw-r--r--win32/file.c14
4 files changed, 29 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d5deaa422..76578db53a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Fri May 29 14:00:16 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* marshal.c (r_symreal): register the symbol name first so that
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index bd69addef6..c0f92ec820 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -447,6 +447,7 @@ class TestFileExhaustive < Test::Unit::TestCase
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::TestCase
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(""))
diff --git a/version.h b/version.h
index ae17b004d8..6bb7e16473 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#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
diff --git a/win32/file.c b/win32/file.c
index 0c5fda9611..d0e0864b3f 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -415,6 +415,8 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
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, VALUE dname, int abs_mode, int long_na
/* 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, VALUE dname, int abs_mode, int long_na
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 */