[前][次][番号順一覧][スレッド一覧]

ruby-changes:16800

From: nobu <ko1@a...>
Date: Fri, 30 Jul 2010 08:33:41 +0900 (JST)
Subject: [ruby-changes:16800] Ruby:r28795 (trunk, ruby_1_8): * file.c (file_expand_path): should check if could find user.

nobu	2010-07-30 08:33:21 +0900 (Fri, 30 Jul 2010)

  New Revision: 28795

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28795

  Log:
    * file.c (file_expand_path): should check if could find user.
      [ruby-core:31538]

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/file.c
    branches/ruby_1_8/test/ruby/test_file_exhaustive.rb
    trunk/ChangeLog
    trunk/file.c
    trunk/test/ruby/test_file_exhaustive.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28794)
+++ ChangeLog	(revision 28795)
@@ -1,3 +1,8 @@
+Fri Jul 30 08:33:20 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (file_expand_path): should check if could find user.
+	  [ruby-core:31538]
+
 Fri Jul 30 07:59:53 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* util.c (ruby_add_suffix): fixed a bug returning uninitialized
Index: test/ruby/test_file_exhaustive.rb
===================================================================
--- test/ruby/test_file_exhaustive.rb	(revision 28794)
+++ test/ruby/test_file_exhaustive.rb	(revision 28795)
@@ -395,11 +395,8 @@
       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
 
Index: file.c
===================================================================
--- file.c	(revision 28794)
+++ file.c	(revision 28795)
@@ -2865,7 +2865,9 @@
 	    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;
     }
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 28794)
+++ ruby_1_8/ChangeLog	(revision 28795)
@@ -1,3 +1,8 @@
+Fri Jul 30 08:33:20 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (file_expand_path): should check if could find user.
+	  [ruby-core:31538]
+
 Fri Jul 30 07:59:53 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* util.c (ruby_add_suffix): fixed a bug returning uninitialized
Index: ruby_1_8/test/ruby/test_file_exhaustive.rb
===================================================================
--- ruby_1_8/test/ruby/test_file_exhaustive.rb	(revision 28794)
+++ ruby_1_8/test/ruby/test_file_exhaustive.rb	(revision 28795)
@@ -353,6 +353,9 @@
       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
Index: ruby_1_8/file.c
===================================================================
--- ruby_1_8/file.c	(revision 28794)
+++ ruby_1_8/file.c	(revision 28795)
@@ -2554,6 +2554,8 @@
 	    strcpy(buf, pwPtr->pw_dir);
 	    p = buf + strlen(pwPtr->pw_dir);
 	    endpwent();
+#else
+	    rb_raise(rb_eArgError, "can't find user %s", buf);
 #endif
 	}
     }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]