1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* file.c (file_expand_path): should check if could find user.

[ruby-core:31538]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@28795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-07-29 23:33:21 +00:00
parent 209cf1351b
commit f2c87d5395
3 changed files with 10 additions and 0 deletions

View file

@ -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

2
file.c
View file

@ -2554,6 +2554,8 @@ file_expand_path(fname, dname, result)
strcpy(buf, pwPtr->pw_dir);
p = buf + strlen(pwPtr->pw_dir);
endpwent();
#else
rb_raise(rb_eArgError, "can't find user %s", buf);
#endif
}
}

View file

@ -353,6 +353,9 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_equal(@file, File.expand_path(@file + "."))
assert_equal(@file, File.expand_path(@file + "::$DATA"))
end
assert_kind_of(String, File.expand_path("~"))
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
def test_basename