diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-29 23:33:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-29 23:33:21 +0000 |
commit | a99de8466396ba4d056c126040dbf19ca5af20ff (patch) | |
tree | e50abe002122eabe64b9a040847eafb2920b5247 | |
parent | 7ae7ac4abab04f4351ae84f63f81b61a41843aff (diff) |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | file.c | 4 | ||||
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 7 |
3 files changed, 10 insertions, 6 deletions
@@ -1,3 +1,8 @@ +Fri Jul 30 08:33:20 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (file_expand_path): should check if could find user. + [ruby-core:31538] + Fri Jul 30 07:59:53 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> * util.c (ruby_add_suffix): fixed a bug returning uninitialized @@ -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 |