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

ruby-changes:29231

From: nobu <ko1@a...>
Date: Thu, 13 Jun 2013 22:12:46 +0900 (JST)
Subject: [ruby-changes:29231] nobu:r41283 (trunk): fileutils.rb: fix traversal loop

nobu	2013-06-13 22:12:35 +0900 (Thu, 13 Jun 2013)

  New Revision: 41283

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

  Log:
    fileutils.rb: fix traversal loop
    
    * lib/fileutils.rb (FileUtils#rmdir): fix traversal loop, not trying
      remove same directory only.

  Modified files:
    trunk/ChangeLog
    trunk/lib/fileutils.rb
    trunk/test/fileutils/test_fileutils.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41282)
+++ ChangeLog	(revision 41283)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun 13 22:12:32 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/fileutils.rb (FileUtils#rmdir): fix traversal loop, not trying
+	  remove same directory only.
+
 Thu Jun 13 21:30:14 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (opt-dir), tool/ifchange: get rid of "alternate value"
Index: lib/fileutils.rb
===================================================================
--- lib/fileutils.rb	(revision 41282)
+++ lib/fileutils.rb	(revision 41283)
@@ -273,6 +273,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L273
         Dir.rmdir(dir = remove_tailing_slash(dir))
         if parents
           until (parent = File.dirname(dir)) == '.' or parent == dir
+            dir = parent
             Dir.rmdir(dir)
           end
         end
Index: test/fileutils/test_fileutils.rb
===================================================================
--- test/fileutils/test_fileutils.rb	(revision 41282)
+++ test/fileutils/test_fileutils.rb	(revision 41283)
@@ -1239,6 +1239,7 @@ class TestFileUtils https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L1239
     assert_nothing_raised(Errno::ENOENT) {
       rmdir(subdir, parents: true)
     }
+    assert_file_not_exist(subdir)
     assert_file_not_exist('data/sub')
     assert_directory('data')
   end

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

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