Skip to content

Commit

Permalink
Merge pull request #8 from nobu/h1-1131465
Browse files Browse the repository at this point in the history
Make usable chars more strict
  • Loading branch information
hsbt committed Apr 5, 2021
2 parents 759a7c9 + adf294b commit 93798c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/tmpdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def tmpdir
Dir.tmpdir
end

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

class << (RANDOM = Random.new)
MAX = 36**6 # < 0x100000000
Expand Down
6 changes: 4 additions & 2 deletions test/test_tmpdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ def assert_mktmpdir_traversal
target = target.chomp('/') + '/'
traversal_path = target.sub(/\A\w:/, '') # for DOSISH
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

0 comments on commit 93798c0

Please sign in to comment.