diff --git a/ChangeLog b/ChangeLog index d5dd635..23aaa42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +Sun Nov 18 02:50:12 2012 Luis Lavena + + * win32/file.c (replace_to_long_name): correct logic around wildcard + characters detection and ensure wide-chars are used as pattern. + [ruby-core:49451] [Bug #7374] + +Sat Nov 17 21:45:12 Luis Lavena + + * win32/file.c (replace_to_long_name): skip expansion for all wildcard + characters. + [ruby-core:49451] [Bug #7374] + + * test/ruby/test_file_exhaustive.rb: add more assertions to test. + +Sat Nov 17 07:35:15 2012 Luis Lavena + + * win32/file.c (replace_to_long_name): skip automatic path expansion + when wildcard character is used. [ruby-core:49451] [Bug #7374] + + * test/ruby/test_file_exhaustive.rb: add a test for above. + Thu Nov 15 15:17:11 2012 Nobuyoshi Nakada * gc.c (free_method_entry_i): method entry may be in diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index f3c36aa..d80c430 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -601,6 +601,13 @@ class TestFileExhaustive < Test::Unit::TestCase assert_equal("#{DRIVE}/dir", File.expand_path("#{DRIVE}/./dir")) end + def test_expand_path_does_not_expand_wildcards + assert_equal("#{DRIVE}/*", File.expand_path("./*", "#{DRIVE}/")) + assert_equal("#{Dir.pwd}/*", File.expand_path("./*", Dir.pwd)) + assert_equal("#{DRIVE}/?", File.expand_path("./?", "#{DRIVE}/")) + assert_equal("#{Dir.pwd}/?", File.expand_path("./?", Dir.pwd)) + end if DRIVE + def test_expand_path_does_not_modify_the_string_argument str = "./a/b/../c" assert_equal("#{Dir.pwd}/a/c", File.expand_path(str, Dir.pwd)) diff --git a/win32/file.c b/win32/file.c index e3b50b4..dfe1224 100644 --- a/win32/file.c +++ b/win32/file.c @@ -276,6 +276,11 @@ replace_to_long_name(wchar_t **wfullpath, size_t size, int heap) return size; } + /* skip long name conversion if path contains wildcard characters */ + if (wcspbrk(pos, L"*?")) { + return size; + } + pos = *wfullpath + size - 1; while (!IS_DIR_SEPARATOR_P(*pos) && pos != *wfullpath) { if (!extension_len && *pos == L'.') {