Bug #14485 ยป file-path-taint.patch
file.c | ||
---|---|---|
rb_raise(rb_eIOError, "File is unnamed (TMPFILE?)");
|
||
}
|
||
return rb_obj_taint(rb_str_dup(fptr->pathv));
|
||
return rb_str_dup(fptr->pathv);
|
||
}
|
||
static size_t
|
test/ruby/test_file_exhaustive.rb | ||
---|---|---|
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
|