summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-29 23:33:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-29 23:33:21 +0000
commitf2c87d53953fad3c674c72081e5f3b86391d4dbd (patch)
tree682265ae97c0083137e387c8fd829e374c1d37c6
parent209cf1351b2c25b0e1c9ace3411ab3c2257d1360 (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/branches/ruby_1_8@28795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--file.c2
-rw-r--r--test/ruby/test_file_exhaustive.rb3
3 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a4608fe106..3e5afa754e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/file.c b/file.c
index bb240cb0b9..5abb72ddb8 100644
--- a/file.c
+++ b/file.c
@@ -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
}
}
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index 5c34c915f8..22039bafc4 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -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