Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make usable chars more strict #8

Merged
merged 1 commit into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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