summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/slice_spec.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-24 20:59:12 -0700
committerJeremy Evans <code@jeremyevans.net>2019-11-18 01:00:25 +0200
commitffd0820ab317542f8780aac475da590a4bdbc7a8 (patch)
tree6a5d774933c15fd2b9ea948bd3ae2fa587faaf82 /spec/ruby/core/string/slice_spec.rb
parentc5c05460ac20abcbc0ed686eb4acf06da7a39a79 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2476
Diffstat (limited to 'spec/ruby/core/string/slice_spec.rb')
-rw-r--r--spec/ruby/core/string/slice_spec.rb108
1 files changed, 59 insertions, 49 deletions
diff --git a/spec/ruby/core/string/slice_spec.rb b/spec/ruby/core/string/slice_spec.rb
index 2af663117c..f9f4938af3 100644
--- a/spec/ruby/core/string/slice_spec.rb
+++ b/spec/ruby/core/string/slice_spec.rb
@@ -94,12 +94,14 @@ describe "String#slice! with index, length" do
a.should == "h"
end
- it "always taints resulting strings when self is tainted" do
- str = "hello world"
- str.taint
+ ruby_version_is ''...'2.7' do
+ it "always taints resulting strings when self is tainted" do
+ str = "hello world"
+ str.taint
- str.slice!(0, 0).tainted?.should == true
- str.slice!(2, 1).tainted?.should == true
+ str.slice!(0, 0).tainted?.should == true
+ str.slice!(2, 1).tainted?.should == true
+ end
end
it "returns nil if the given position is out of self" do
@@ -184,12 +186,14 @@ describe "String#slice! Range" do
b.should == "hello"
end
- it "always taints resulting strings when self is tainted" do
- str = "hello world"
- str.taint
+ ruby_version_is ''...'2.7' do
+ it "always taints resulting strings when self is tainted" do
+ str = "hello world"
+ str.taint
- str.slice!(0..0).tainted?.should == true
- str.slice!(2..3).tainted?.should == true
+ str.slice!(0..0).tainted?.should == true
+ str.slice!(2..3).tainted?.should == true
+ end
end
it "returns subclass instances" do
@@ -271,26 +275,28 @@ describe "String#slice! with Regexp" do
s.should == "this is a string"
end
- it "always taints resulting strings when self or regexp is tainted" do
- strs = ["hello world"]
- strs += strs.map { |s| s.dup.taint }
+ ruby_version_is ''...'2.7' do
+ it "always taints resulting strings when self or regexp is tainted" do
+ strs = ["hello world"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str = str.dup
- str.slice!(//).tainted?.should == str.tainted?
- str.slice!(/hello/).tainted?.should == str.tainted?
+ strs.each do |str|
+ str = str.dup
+ str.slice!(//).tainted?.should == str.tainted?
+ str.slice!(/hello/).tainted?.should == str.tainted?
- tainted_re = /./
- tainted_re.taint
+ tainted_re = /./
+ tainted_re.taint
- str.slice!(tainted_re).tainted?.should == true
+ str.slice!(tainted_re).tainted?.should == true
+ end
end
- end
- it "doesn't taint self when regexp is tainted" do
- s = "hello"
- s.slice!(/./.taint)
- s.tainted?.should == false
+ it "doesn't taint self when regexp is tainted" do
+ s = "hello"
+ s.slice!(/./.taint)
+ s.tainted?.should == false
+ end
end
it "returns subclass instances" do
@@ -330,26 +336,28 @@ describe "String#slice! with Regexp, index" do
str.should == "ho here"
end
- it "always taints resulting strings when self or regexp is tainted" do
- strs = ["hello world"]
- strs += strs.map { |s| s.dup.taint }
+ ruby_version_is ''...'2.7' do
+ it "always taints resulting strings when self or regexp is tainted" do
+ strs = ["hello world"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str = str.dup
- str.slice!(//, 0).tainted?.should == str.tainted?
- str.slice!(/hello/, 0).tainted?.should == str.tainted?
+ strs.each do |str|
+ str = str.dup
+ str.slice!(//, 0).tainted?.should == str.tainted?
+ str.slice!(/hello/, 0).tainted?.should == str.tainted?
- tainted_re = /(.)(.)(.)/
- tainted_re.taint
+ tainted_re = /(.)(.)(.)/
+ tainted_re.taint
- str.slice!(tainted_re, 1).tainted?.should == true
+ str.slice!(tainted_re, 1).tainted?.should == true
+ end
end
- end
- it "doesn't taint self when regexp is tainted" do
- s = "hello"
- s.slice!(/(.)(.)/.taint, 1)
- s.tainted?.should == false
+ it "doesn't taint self when regexp is tainted" do
+ s = "hello"
+ s.slice!(/(.)(.)/.taint, 1)
+ s.tainted?.should == false
+ end
end
it "returns nil if there was no match" do
@@ -416,17 +424,19 @@ describe "String#slice! with String" do
c.should == "he hello"
end
- it "taints resulting strings when other is tainted" do
- strs = ["", "hello world", "hello"]
- strs += strs.map { |s| s.dup.taint }
+ ruby_version_is ''...'2.7' do
+ it "taints resulting strings when other is tainted" do
+ strs = ["", "hello world", "hello"]
+ strs += strs.map { |s| s.dup.taint }
- strs.each do |str|
- str = str.dup
- strs.each do |other|
- other = other.dup
- r = str.slice!(other)
+ strs.each do |str|
+ str = str.dup
+ strs.each do |other|
+ other = other.dup
+ r = str.slice!(other)
- r.tainted?.should == !r.nil? & other.tainted?
+ r.tainted?.should == !r.nil? & other.tainted?
+ end
end
end
end