Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6eab49a

Browse files
committed
Revert "Do not always taint the result of File#path"
This reverts commit 1a759bf. This fails on some operating systems.
1 parent 177731a commit 6eab49a

File tree

3 files changed

+1
-22
lines changed

3 files changed

+1
-22
lines changed

file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ rb_file_path(VALUE obj)
475475
rb_raise(rb_eIOError, "File is unnamed (TMPFILE?)");
476476
}
477477

478-
return rb_str_dup(fptr->pathv);
478+
return rb_obj_taint(rb_str_dup(fptr->pathv));
479479
}
480480

481481
static size_t

test/readline/test_readline.rb

-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ def test_readline
4141
assert_equal("> ", stdout.read(2))
4242
assert_equal(1, Readline::HISTORY.length)
4343
assert_equal("hello", Readline::HISTORY[0])
44-
45-
# Work around lack of SecurityError in Reline
46-
# test mode with tainted prompt
47-
return if kind_of?(TestRelineAsReadline)
48-
4944
Thread.start {
5045
$SAFE = 1
5146
assert_raise(SecurityError) do

test/ruby/test_file_exhaustive.rb

-16
Original file line numberDiff line numberDiff line change
@@ -187,22 +187,6 @@ class << o; self; end.class_eval do
187187
end
188188
end
189189

190-
def test_path_taint
191-
[regular_file, utf8_file].each do |file|
192-
assert_equal(false, File.open(file) {|f| f.path}.tainted?)
193-
assert_equal(true, File.open(file.dup.taint) {|f| f.path}.tainted?)
194-
o = Object.new
195-
class << o; self; end.class_eval do
196-
define_method(:to_path) { file }
197-
end
198-
assert_equal(false, File.open(o) {|f| f.path}.tainted?)
199-
class << o; self; end.class_eval do
200-
define_method(:to_path) { file.dup.taint }
201-
end
202-
assert_equal(true, File.open(o) {|f| f.path}.tainted?)
203-
end
204-
end
205-
206190
def assert_integer(n)
207191
assert_kind_of(Integer, n)
208192
end

0 commit comments

Comments
 (0)