mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Revert "Do not always taint the result of File#path"
This reverts commit 1a759bfe5d
.
This fails on some operating systems.
This commit is contained in:
parent
177731aadf
commit
6eab49a40a
3 changed files with 1 additions and 22 deletions
2
file.c
2
file.c
|
@ -475,7 +475,7 @@ rb_file_path(VALUE obj)
|
|||
rb_raise(rb_eIOError, "File is unnamed (TMPFILE?)");
|
||||
}
|
||||
|
||||
return rb_str_dup(fptr->pathv);
|
||||
return rb_obj_taint(rb_str_dup(fptr->pathv));
|
||||
}
|
||||
|
||||
static size_t
|
||||
|
|
|
@ -41,11 +41,6 @@ module BasetestReadline
|
|||
assert_equal("> ", stdout.read(2))
|
||||
assert_equal(1, Readline::HISTORY.length)
|
||||
assert_equal("hello", Readline::HISTORY[0])
|
||||
|
||||
# Work around lack of SecurityError in Reline
|
||||
# test mode with tainted prompt
|
||||
return if kind_of?(TestRelineAsReadline)
|
||||
|
||||
Thread.start {
|
||||
$SAFE = 1
|
||||
assert_raise(SecurityError) do
|
||||
|
|
|
@ -187,22 +187,6 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_path_taint
|
||||
[regular_file, utf8_file].each do |file|
|
||||
assert_equal(false, File.open(file) {|f| f.path}.tainted?)
|
||||
assert_equal(true, File.open(file.dup.taint) {|f| f.path}.tainted?)
|
||||
o = Object.new
|
||||
class << o; self; end.class_eval do
|
||||
define_method(:to_path) { file }
|
||||
end
|
||||
assert_equal(false, File.open(o) {|f| f.path}.tainted?)
|
||||
class << o; self; end.class_eval do
|
||||
define_method(:to_path) { file.dup.taint }
|
||||
end
|
||||
assert_equal(true, File.open(o) {|f| f.path}.tainted?)
|
||||
end
|
||||
end
|
||||
|
||||
def assert_integer(n)
|
||||
assert_kind_of(Integer, n)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue