Skip to content

Commit 59cfa0b

Browse files
committed
Backport a tmpdir fix.
Remove other then alphanumeric and some punctuations considered filesystem-safe, instead of removing some unsafe chars only.
1 parent b59e5a6 commit 59cfa0b

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

lib/tmpdir.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def tmpdir
108108
Dir.tmpdir
109109
end
110110

111-
UNUSABLE_CHARS = [File::SEPARATOR, File::ALT_SEPARATOR, File::PATH_SEPARATOR, ":"].uniq.join("").freeze
111+
UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
112112

113113
def create(basename, tmpdir=nil, max_try: nil, **opts)
114114
origdir = tmpdir

test/test_tmpdir.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ def assert_mktmpdir_traversal
8686
traversal_path = Array.new(target.count('/')-2, '..').join('/') + traversal_path
8787
actual = yield traversal_path
8888
assert_not_send([File.absolute_path(actual), :start_with?, target])
89+
[File::SEPARATOR, File::ALT_SEPARATOR].compact.each do |separator|
90+
actual = yield traversal_path.tr('/', separator)
91+
assert_not_send([File.absolute_path(actual), :start_with?, target])
92+
end
8993
end
9094
end
9195
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
33
#define RUBY_VERSION_TEENY 3
44
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
5-
#define RUBY_PATCHLEVEL 181
5+
#define RUBY_PATCHLEVEL 182
66

77
#define RUBY_RELEASE_YEAR 2021
88
#define RUBY_RELEASE_MONTH 4

0 commit comments

Comments
 (0)