Skip to content

Commit f9b1ab8

Browse files
jeremyevanshsbt
authored andcommitted
Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
1 parent e2cc830 commit f9b1ab8

File tree

2 files changed

+4
-59
lines changed

2 files changed

+4
-59
lines changed

ext/pathname/pathname.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ path_initialize(VALUE self, VALUE arg)
110110
str = rb_obj_dup(str);
111111

112112
set_strpath(self, str);
113-
OBJ_INFECT(self, str);
114113
return self;
115114
}
116115

@@ -134,31 +133,25 @@ path_freeze(VALUE self)
134133
* call-seq:
135134
* pathname.taint -> obj
136135
*
137-
* Taints this Pathname.
138-
*
139-
* See Object.taint.
136+
* Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
140137
*/
141138
static VALUE
142139
path_taint(VALUE self)
143140
{
144-
rb_call_super(0, 0);
145-
rb_obj_taint(get_strpath(self));
141+
rb_warning("Pathname#taint is deprecated and will be removed in Ruby 3.2.");
146142
return self;
147143
}
148144

149145
/*
150146
* call-seq:
151147
* pathname.untaint -> obj
152148
*
153-
* Untaints this Pathname.
154-
*
155-
* See Object.untaint.
149+
* Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
156150
*/
157151
static VALUE
158152
path_untaint(VALUE self)
159153
{
160-
rb_call_super(0, 0);
161-
rb_obj_untaint(get_strpath(self));
154+
rb_warning("Pathname#untaint is deprecated and will be removed in Ruby 3.2.");
162155
return self;
163156
}
164157

@@ -308,7 +301,6 @@ path_sub_ext(VALUE self, VALUE repl)
308301
}
309302
str2 = rb_str_subseq(str, 0, ext-p);
310303
rb_str_append(str2, repl);
311-
OBJ_INFECT(str2, str);
312304
return rb_class_new_instance(1, &str2, rb_obj_class(self));
313305
}
314306

test/pathname/test_pathname.rb

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -592,39 +592,6 @@ def test_null_character
592592
assert_raise(ArgumentError) { Pathname.new("\0") }
593593
end
594594

595-
def test_taint
596-
obj = Pathname.new("a"); assert_same(obj, obj.taint)
597-
obj = Pathname.new("a"); assert_same(obj, obj.untaint)
598-
599-
assert_equal(false, Pathname.new("a" ) .tainted?)
600-
assert_equal(false, Pathname.new("a" ) .to_s.tainted?)
601-
assert_equal(true, Pathname.new("a" ).taint .tainted?)
602-
assert_equal(true, Pathname.new("a" ).taint.to_s.tainted?)
603-
assert_equal(true, Pathname.new("a".dup.taint) .tainted?)
604-
assert_equal(true, Pathname.new("a".dup.taint) .to_s.tainted?)
605-
assert_equal(true, Pathname.new("a".dup.taint).taint .tainted?)
606-
assert_equal(true, Pathname.new("a".dup.taint).taint.to_s.tainted?)
607-
608-
str = "a".dup
609-
path = Pathname.new(str)
610-
str.taint
611-
assert_equal(false, path .tainted?)
612-
assert_equal(false, path.to_s.tainted?)
613-
end
614-
615-
def test_untaint
616-
obj = Pathname.new("a"); assert_same(obj, obj.untaint)
617-
618-
assert_equal(false, Pathname.new("a").taint.untaint .tainted?)
619-
assert_equal(false, Pathname.new("a").taint.untaint.to_s.tainted?)
620-
621-
str = "a".dup.taint
622-
path = Pathname.new(str)
623-
str.untaint
624-
assert_equal(true, path .tainted?)
625-
assert_equal(true, path.to_s.tainted?)
626-
end
627-
628595
def test_freeze
629596
obj = Pathname.new("a"); assert_same(obj, obj.freeze)
630597

@@ -638,20 +605,6 @@ def test_freeze
638605
assert_equal(false, Pathname.new("a".freeze).freeze.to_s.frozen?)
639606
end
640607

641-
def test_freeze_and_taint
642-
obj = Pathname.new("a")
643-
obj.freeze
644-
assert_equal(false, obj.tainted?)
645-
assert_raise(FrozenError) { obj.taint }
646-
647-
obj = Pathname.new("a")
648-
obj.taint
649-
assert_equal(true, obj.tainted?)
650-
obj.freeze
651-
assert_equal(true, obj.tainted?)
652-
assert_nothing_raised { obj.taint }
653-
end
654-
655608
def test_to_s
656609
str = "a"
657610
obj = Pathname.new(str)

0 commit comments

Comments
 (0)