From a99de8466396ba4d056c126040dbf19ca5af20ff Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 29 Jul 2010 23:33:21 +0000 Subject: [PATCH] * file.c (file_expand_path): should check if could find user. [ruby-core:31538] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ file.c | 4 +++- test/ruby/test_file_exhaustive.rb | 7 ++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb7732c00b..55d08c087a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 30 08:33:20 2010 Nobuyoshi Nakada + + * file.c (file_expand_path): should check if could find user. + [ruby-core:31538] + Fri Jul 30 07:59:53 2010 Nobuyoshi Nakada * util.c (ruby_add_suffix): fixed a bug returning uninitialized diff --git a/file.c b/file.c index 8ce1f8dfe3..355f8e8a8a 100644 --- a/file.c +++ b/file.c @@ -2865,7 +2865,9 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) buf = p + 1; p += s-b; } - rb_home_dir(buf, result); + if (NIL_P(rb_home_dir(buf, result))) { + rb_raise(rb_eArgError, "can't find user %s", buf); + } BUFINIT(); p = pend; } diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 35d6bcff14..ee4df6b154 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -395,11 +395,8 @@ class TestFileExhaustive < Test::Unit::TestCase assert_equal(@file, File.expand_path(@file + "::$DATA")) end assert_kind_of(String, File.expand_path("~")) - unless /mingw|mswin/ =~ RUBY_PLATFORM - assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") } - assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") } - end - + assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") } + assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") } assert_incompatible_encoding {|d| File.expand_path(d)} end