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

ruby-changes:65789

From: nagachika <ko1@a...>
Date: Mon, 5 Apr 2021 20:51:04 +0900 (JST)
Subject: [ruby-changes:65789] 59cfa0b134 (ruby_2_7): Backport a tmpdir fix.

https://git.ruby-lang.org/ruby.git/commit/?id=59cfa0b134

From 59cfa0b1346067e36ae11fc6c317693ce4b9833a Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Mon, 5 Apr 2021 20:35:34 +0900
Subject: Backport a tmpdir fix.

Remove other then alphanumeric and some punctuations considered
filesystem-safe, instead of removing some unsafe chars only.
---
 lib/tmpdir.rb       | 2 +-
 test/test_tmpdir.rb | 4 ++++
 version.h           | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 1bbf7ea..5e42e8e 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -108,7 +108,7 @@ class Dir https://github.com/ruby/ruby/blob/trunk/lib/tmpdir.rb#L108
       Dir.tmpdir
     end
 
-    UNUSABLE_CHARS = [File::SEPARATOR, File::ALT_SEPARATOR, File::PATH_SEPARATOR, ":"].uniq.join("").freeze
+    UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
 
     def create(basename, tmpdir=nil, max_try: nil, **opts)
       origdir = tmpdir
diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb
index 50583b5..ea2cc12 100644
--- a/test/test_tmpdir.rb
+++ b/test/test_tmpdir.rb
@@ -86,6 +86,10 @@ class TestTmpdir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_tmpdir.rb#L86
       traversal_path = Array.new(target.count('/')-2, '..').join('/') + traversal_path
       actual = yield traversal_path
       assert_not_send([File.absolute_path(actual), :start_with?, target])
+      [File::SEPARATOR, File::ALT_SEPARATOR].compact.each do |separator|
+        actual = yield traversal_path.tr('/', separator)
+        assert_not_send([File.absolute_path(actual), :start_with?, target])
+      end
     end
   end
 end
diff --git a/version.h b/version.h
index f910e00..c5d337f 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 3
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 181
+#define RUBY_PATCHLEVEL 182
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 4
-- 
cgit v1.1


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

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