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

ruby-changes:50789

From: usa <ko1@a...>
Date: Wed, 28 Mar 2018 19:29:20 +0900 (JST)
Subject: [ruby-changes:50789] usa:r62995 (ruby_2_3): merge revision(s) 62990:

usa	2018-03-28 19:29:15 +0900 (Wed, 28 Mar 2018)

  New Revision: 62995

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62995

  Log:
    merge revision(s) 62990:
    
    Ignore file separator from tmpfile/tmpdir name.
    
    From: SHIBATA Hiroshi <hsbt@r...>

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/lib/tmpdir.rb
    branches/ruby_2_3/test/test_tempfile.rb
    branches/ruby_2_3/test/test_tmpdir.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/lib/tmpdir.rb
===================================================================
--- ruby_2_3/lib/tmpdir.rb	(revision 62994)
+++ ruby_2_3/lib/tmpdir.rb	(revision 62995)
@@ -109,8 +109,10 @@ class Dir https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/tmpdir.rb#L109
     def make_tmpname((prefix, suffix), n)
       prefix = (String.try_convert(prefix) or
                 raise ArgumentError, "unexpected prefix: #{prefix.inspect}")
+      prefix = prefix.delete("#{File::SEPARATOR}#{File::ALT_SEPARATOR}")
       suffix &&= (String.try_convert(suffix) or
                   raise ArgumentError, "unexpected suffix: #{suffix.inspect}")
+      suffix &&= suffix.delete("#{File::SEPARATOR}#{File::ALT_SEPARATOR}")
       t = Time.now.strftime("%Y%m%d")
       path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}".dup
       path << "-#{n}" if n
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 62994)
+++ ruby_2_3/version.h	(revision 62995)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.7"
 #define RUBY_RELEASE_DATE "2018-03-28"
-#define RUBY_PATCHLEVEL 451
+#define RUBY_PATCHLEVEL 452
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_3/test/test_tmpdir.rb
===================================================================
--- ruby_2_3/test/test_tmpdir.rb	(revision 62994)
+++ ruby_2_3/test/test_tmpdir.rb	(revision 62995)
@@ -56,4 +56,21 @@ class TestTmpdir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/test_tmpdir.rb#L56
       assert_kind_of(String, d)
     }
   end
+
+  TRAVERSAL_PATH = Array.new(Dir.pwd.split('/').count, '..').join('/') + Dir.pwd + '/'
+  TRAVERSAL_PATH.delete!(':') if /mswin|mingw/ =~ RUBY_PLATFORM
+
+  def test_mktmpdir_traversal
+    expect = Dir.glob(TRAVERSAL_PATH + '*').count
+    Dir.mktmpdir(TRAVERSAL_PATH + 'foo')
+    actual = Dir.glob(TRAVERSAL_PATH + '*').count
+    assert_equal expect, actual
+  end
+
+  def test_mktmpdir_traversal_array
+    expect = Dir.glob(TRAVERSAL_PATH + '*').count
+    Dir.mktmpdir([TRAVERSAL_PATH, 'foo'])
+    actual = Dir.glob(TRAVERSAL_PATH + '*').count
+    assert_equal expect, actual
+  end
 end
Index: ruby_2_3/test/test_tempfile.rb
===================================================================
--- ruby_2_3/test/test_tempfile.rb	(revision 62994)
+++ ruby_2_3/test/test_tempfile.rb	(revision 62995)
@@ -352,5 +352,31 @@ puts Tempfile.new('foo').path https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/test_tempfile.rb#L352
     f.close if f && !f.closed?
     File.unlink path if path
   end
-end
 
+  TRAVERSAL_PATH = Array.new(Dir.pwd.split('/').count, '..').join('/') + Dir.pwd + '/'
+
+  def test_open_traversal_dir
+    expect = Dir.glob(TRAVERSAL_PATH + '*').count
+    t = Tempfile.open([TRAVERSAL_PATH, 'foo'])
+    actual = Dir.glob(TRAVERSAL_PATH + '*').count
+    assert_equal expect, actual
+  ensure
+    t.close!
+  end
+
+  def test_new_traversal_dir
+    expect = Dir.glob(TRAVERSAL_PATH + '*').count
+    t = Tempfile.new(TRAVERSAL_PATH + 'foo')
+    actual = Dir.glob(TRAVERSAL_PATH + '*').count
+    assert_equal expect, actual
+  ensure
+    t.close!
+  end
+
+  def test_create_traversal_dir
+    expect = Dir.glob(TRAVERSAL_PATH + '*').count
+    Tempfile.create(TRAVERSAL_PATH + 'foo')
+    actual = Dir.glob(TRAVERSAL_PATH + '*').count
+    assert_equal expect, actual
+  end
+end
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 62994)
+++ ruby_2_3/ChangeLog	(revision 62995)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Wed Mar 28 19:29:03 2018  SHIBATA Hiroshi  <hsbt@r...>
+
+	Ignore file separator from tmpfile/tmpdir name.
+
 Wed Mar 28 19:24:20 2018  Nobuyoshi Nakada  <nobu@r...>
 
 	dir.c: check NUL bytes
Index: ruby_2_3
===================================================================
--- ruby_2_3	(revision 62994)
+++ ruby_2_3	(revision 62995)

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r62990

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

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