summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-21 03:47:36 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-21 03:47:36 +0000
commit2098b5aea5e197f23a40d95933306bf09e782aa3 (patch)
tree2ec55f62558b9365cf0ea5119068928e51a2d9c1 /win32
parent97c3018a5d95005a5b49086c0522a5ba0dbed39f (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_2@49671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/file.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/win32/file.c b/win32/file.c
index a50d6d8638..0fb6d5fa67 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -398,6 +398,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'~') {
@@ -492,15 +494,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;
}
}
@@ -531,6 +529,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 */