diff options
author | Benoit Daloze <eregontp@gmail.com> | 2022-04-25 14:53:54 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2022-04-25 14:53:54 +0200 |
commit | 45cf4f218728a15eb36d14a6c9912086525f5e3f (patch) | |
tree | 2aa93fadcb904c226f722dde47827098b87a9846 /spec/ruby/core/string | |
parent | 6ae81d49b52563a6720d666a6118ffa6e484f398 (diff) | |
download | ruby-45cf4f218728a15eb36d14a6c9912086525f5e3f.tar.gz |
Update to ruby/spec@3affe1e
Diffstat (limited to 'spec/ruby/core/string')
43 files changed, 16 insertions, 1152 deletions
diff --git a/spec/ruby/core/string/b_spec.rb b/spec/ruby/core/string/b_spec.rb index b2e3d326ba..37c7994700 100644 --- a/spec/ruby/core/string/b_spec.rb +++ b/spec/ruby/core/string/b_spec.rb @@ -12,13 +12,4 @@ describe "String#b" do str.b.should_not equal(str) str.should == "こんちには" end - - ruby_version_is ''...'2.7' do - it "copies own tainted/untrusted status to the returning value" do - utf_8 = "こんちには".taint.untrust - ret = utf_8.b - ret.tainted?.should be_true - ret.untrusted?.should be_true - end - end end diff --git a/spec/ruby/core/string/capitalize_spec.rb b/spec/ruby/core/string/capitalize_spec.rb index 21df18a5ae..ca8df88fec 100644 --- a/spec/ruby/core/string/capitalize_spec.rb +++ b/spec/ruby/core/string/capitalize_spec.rb @@ -12,13 +12,6 @@ describe "String#capitalize" do "123ABC".capitalize.should == "123abc" end - ruby_version_is ''...'2.7' do - it "taints resulting string when self is tainted" do - "".taint.capitalize.should.tainted? - "hello".taint.capitalize.should.tainted? - end - end - describe "full Unicode case mapping" do it "works for all of Unicode with no option" do "äöÜ".capitalize.should == "Äöü" diff --git a/spec/ruby/core/string/center_spec.rb b/spec/ruby/core/string/center_spec.rb index b66015172c..76da6e1e09 100644 --- a/spec/ruby/core/string/center_spec.rb +++ b/spec/ruby/core/string/center_spec.rb @@ -47,16 +47,6 @@ describe "String#center with length, padding" do "radiology".center(8, '-').should == "radiology" end - ruby_version_is ''...'2.7' do - it "taints result when self or padstr is tainted" do - "x".taint.center(4).should.tainted? - "x".taint.center(0).should.tainted? - "".taint.center(0).should.tainted? - "x".taint.center(4, "*").should.tainted? - "x".center(4, "*".taint).should.tainted? - end - end - it "calls #to_int to convert length to an integer" do "_".center(3.8, "^").should == "^_^" @@ -113,14 +103,6 @@ describe "String#center with length, padding" do end end - ruby_version_is ''...'2.7' do - it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do - "hello".center(4, 'X'.taint).tainted?.should be_false - "hello".center(5, 'X'.taint).tainted?.should be_false - "hello".center(6, 'X'.taint).tainted?.should be_true - end - end - describe "with width" do it "returns a String in the same encoding as the original" do str = "abc".force_encoding Encoding::IBM437 diff --git a/spec/ruby/core/string/chomp_spec.rb b/spec/ruby/core/string/chomp_spec.rb index 3d6207f876..c03bfc7951 100644 --- a/spec/ruby/core/string/chomp_spec.rb +++ b/spec/ruby/core/string/chomp_spec.rb @@ -40,12 +40,6 @@ describe "String#chomp" do "".chomp.should == "" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp.tainted?.should be_true - end - end - ruby_version_is ''...'3.0' do it "returns subclass instances when called on a subclass" do str = StringSpecs::MyString.new("hello\n").chomp @@ -80,12 +74,6 @@ describe "String#chomp" do str.chomp(nil).should_not equal(str) end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp(nil).tainted?.should be_true - end - end - it "returns an empty String when self is empty" do "".chomp(nil).should == "" end @@ -112,12 +100,6 @@ describe "String#chomp" do "abc\r\n\r\n\r\n".chomp("").should == "abc" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp("").tainted?.should be_true - end - end - it "returns an empty String when self is empty" do "".chomp("").should == "" end @@ -140,12 +122,6 @@ describe "String#chomp" do "abc\r\n\r\n".chomp("\n").should == "abc\r\n" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp("\n").tainted?.should be_true - end - end - it "returns an empty String when self is empty" do "".chomp("\n").should == "" end @@ -178,16 +154,6 @@ describe "String#chomp" do "".chomp("abc").should == "" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp("abc").tainted?.should be_true - end - - it "does not taint the result when the argument is tainted" do - "abc".chomp("abc".taint).tainted?.should be_false - end - end - it "returns an empty String when the argument equals self" do "abc".chomp("abc").should == "" end @@ -232,12 +198,6 @@ describe "String#chomp!" do "".chomp!.should be_nil end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc\n".taint.chomp!.tainted?.should be_true - end - end - it "returns subclass instances when called on a subclass" do str = StringSpecs::MyString.new("hello\n").chomp! str.should be_an_instance_of(StringSpecs::MyString) @@ -280,12 +240,6 @@ describe "String#chomp!" do "abc\r\n\r\n\r\n".chomp!("").should == "abc" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc\n".taint.chomp!("").tainted?.should be_true - end - end - it "returns nil when self is empty" do "".chomp!("").should be_nil end @@ -304,12 +258,6 @@ describe "String#chomp!" do "abc\r\n\r\n".chomp!("\n").should == "abc\r\n" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc\n".taint.chomp!("\n").tainted?.should be_true - end - end - it "returns nil when self is empty" do "".chomp!("\n").should be_nil end @@ -341,16 +289,6 @@ describe "String#chomp!" do it "returns nil when self is empty" do "".chomp!("abc").should be_nil end - - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp!("abc").tainted?.should be_true - end - - it "does not taint the result when the argument is tainted" do - "abc".chomp!("abc".taint).tainted?.should be_false - end - end end it "raises a FrozenError on a frozen instance when it is modified" do diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb index 9b4e7363c6..266d973f67 100644 --- a/spec/ruby/core/string/chop_spec.rb +++ b/spec/ruby/core/string/chop_spec.rb @@ -49,18 +49,6 @@ describe "String#chop" do s.chop.should_not equal(s) end - ruby_version_is ''...'2.7' do - it "taints result when self is tainted" do - "hello".taint.chop.should.tainted? - "".taint.chop.should.tainted? - end - - it "untrusts result when self is untrusted" do - "hello".untrust.chop.should.untrusted? - "".untrust.chop.should.untrusted? - end - end - ruby_version_is ''...'3.0' do it "returns subclass instances when called on a subclass" do StringSpecs::MyString.new("hello\n").chop.should be_an_instance_of(StringSpecs::MyString) diff --git a/spec/ruby/core/string/crypt_spec.rb b/spec/ruby/core/string/crypt_spec.rb index b947702492..06f84c70a4 100644 --- a/spec/ruby/core/string/crypt_spec.rb +++ b/spec/ruby/core/string/crypt_spec.rb @@ -25,21 +25,6 @@ describe "String#crypt" do "mypassword".crypt(obj).should == "$2a$04$0WVaz0pV3jzfZ5G5tpmHWuBQGbkjzgtSc3gJbmdy0GAGMa45MFM2." end - ruby_version_is ''...'2.7' do - it "taints the result if either salt or self is tainted" do - tainted_salt = "$2a$04$0WVaz0pV3jzfZ5G5tpmHWu" - tainted_str = "mypassword" - - tainted_salt.taint - tainted_str.taint - - "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should_not.tainted? - tainted_str.crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should.tainted? - "mypassword".crypt(tainted_salt).should.tainted? - tainted_str.crypt(tainted_salt).should.tainted? - end - end - it "doesn't return subclass instances" do StringSpecs::MyString.new("mypassword").crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should be_an_instance_of(String) "mypassword".crypt(StringSpecs::MyString.new("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")).should be_an_instance_of(String) @@ -85,21 +70,6 @@ describe "String#crypt" do "".crypt(obj).should == "aaQSqAReePlq6" end - ruby_version_is ''...'2.7' do - it "taints the result if either salt or self is tainted" do - tainted_salt = "aa" - tainted_str = "hello" - - tainted_salt.taint - tainted_str.taint - - "hello".crypt("aa").should_not.tainted? - tainted_str.crypt("aa").should.tainted? - "hello".crypt(tainted_salt).should.tainted? - tainted_str.crypt(tainted_salt).should.tainted? - end - end - it "doesn't return subclass instances" do StringSpecs::MyString.new("hello").crypt("aa").should be_an_instance_of(String) "hello".crypt(StringSpecs::MyString.new("aa")).should be_an_instance_of(String) diff --git a/spec/ruby/core/string/delete_prefix_spec.rb b/spec/ruby/core/string/delete_prefix_spec.rb index 8469791f74..a063e443d8 100644 --- a/spec/ruby/core/string/delete_prefix_spec.rb +++ b/spec/ruby/core/string/delete_prefix_spec.rb @@ -21,13 +21,6 @@ describe "String#delete_prefix" do r.should == s end - ruby_version_is ''...'2.7' do - it "taints resulting strings when other is tainted" do - 'hello'.taint.delete_prefix('hell').should.tainted? - 'hello'.taint.delete_prefix('').should.tainted? - end - end - it "doesn't set $~" do $~ = nil diff --git a/spec/ruby/core/string/delete_spec.rb b/spec/ruby/core/string/delete_spec.rb index ebca0b7dae..b91e88b76f 100644 --- a/spec/ruby/core/string/delete_spec.rb +++ b/spec/ruby/core/string/delete_spec.rb @@ -68,15 +68,6 @@ describe "String#delete" do -> { "hello".delete("^h-e") }.should raise_error(ArgumentError) end - ruby_version_is ''...'2.7' do - it "taints result when self is tainted" do - "hello".taint.delete("e").should.tainted? - "hello".taint.delete("a-z").should.tainted? - - "hello".delete("e".taint).should_not.tainted? - end - end - it "tries to convert each set arg to a string using to_str" do other_string = mock('lo') other_string.should_receive(:to_str).and_return("lo") diff --git a/spec/ruby/core/string/delete_suffix_spec.rb b/spec/ruby/core/string/delete_suffix_spec.rb index 12d0ee175e..3d3274bc5b 100644 --- a/spec/ruby/core/string/delete_suffix_spec.rb +++ b/spec/ruby/core/string/delete_suffix_spec.rb @@ -21,13 +21,6 @@ describe "String#delete_suffix" do r.should == s end - ruby_version_is ''...'2.7' do - it "taints resulting strings when other is tainted" do - 'hello'.taint.delete_suffix('ello').should.tainted? - 'hello'.taint.delete_suffix('').should.tainted? - end - end - it "doesn't set $~" do $~ = nil diff --git a/spec/ruby/core/string/downcase_spec.rb b/spec/ruby/core/string/downcase_spec.rb index 4427c9df10..86d8480889 100644 --- a/spec/ruby/core/string/downcase_spec.rb +++ b/spec/ruby/core/string/downcase_spec.rb @@ -68,14 +68,6 @@ describe "String#downcase" do -> { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError) end - ruby_version_is ''...'2.7' do - it "taints result when self is tainted" do - "".taint.downcase.should.tainted? - "x".taint.downcase.should.tainted? - "X".taint.downcase.should.tainted? - end - end - ruby_version_is ''...'3.0' do it "returns a subclass instance for subclasses" do StringSpecs::MyString.new("FOObar").downcase.should be_an_instance_of(StringSpecs::MyString) diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb index 817dec6c4d..79a8b55e6d 100644 --- a/spec/ruby/core/string/dump_spec.rb +++ b/spec/ruby/core/string/dump_spec.rb @@ -3,18 +3,6 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' describe "String#dump" do - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "foo".taint.dump.should.tainted? - "foo\n".taint.dump.should.tainted? - end - - it "untrusts the result if self is untrusted" do - "foo".untrust.dump.should.untrusted? - "foo\n".untrust.dump.should.untrusted? - end - end - it "does not take into account if a string is frozen" do "foo".freeze.dump.should_not.frozen? end diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb index 0aabbacd0e..881b4343d4 100644 --- a/spec/ruby/core/string/element_set_spec.rb +++ b/spec/ruby/core/string/element_set_spec.rb @@ -14,18 +14,6 @@ describe "String#[]= with Integer index" do a.should == "bamelo" end - ruby_version_is ''...'2.7' do - it "taints self if other_str is tainted" do - a = "hello" - a[0] = "".taint - a.should.tainted? - - a = "hello" - a[0] = "x".taint - a.should.tainted? - end - end - it "raises an IndexError without changing self if idx is outside of self" do str = "hello" @@ -493,18 +481,6 @@ describe "String#[]= with Integer index, count" do a.should == "hellobob" end - ruby_version_is ''...'2.7' do - it "taints self if other_str is tainted" do - a = "hello" - a[0, 0] = "".taint - a.should.tainted? - - a = "hello" - a[1, 4] = "x".taint - a.should.tainted? - end - end - it "calls #to_int to convert the index and count objects" do index = mock("string element set index") index.should_receive(:to_int).and_return(-4) diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb index ad41b7e0a2..3211ebbd0a 100644 --- a/spec/ruby/core/string/gsub_spec.rb +++ b/spec/ruby/core/string/gsub_spec.rb @@ -160,56 +160,12 @@ describe "String#gsub with pattern and replacement" do it_behaves_like :string_gsub_named_capture, :gsub - ruby_version_is ''...'2.7' do - it "taints the result if the original string or replacement is tainted" do - hello = "hello" - hello_t = "hello" - a = "a" - a_t = "a" - empty = "" - empty_t = "" - - hello_t.taint; a_t.taint; empty_t.taint - - hello_t.gsub(/./, a).should.tainted? - hello_t.gsub(/./, empty).should.tainted? - - hello.gsub(/./, a_t).should.tainted? - hello.gsub(/./, empty_t).should.tainted? - hello.gsub(//, empty_t).should.tainted? - - hello.gsub(//.taint, "foo").should_not.tainted? - end - end - it "handles pattern collapse" do str = "こにちわ" reg = %r!! str.gsub(reg, ".").should == ".こ.に.ち.わ." end - ruby_version_is ''...'2.7' do - it "untrusts the result if the original string or replacement is untrusted" do - hello = "hello" - hello_t = "hello" - a = "a" - a_t = "a" - empty = "" - empty_t = "" - - hello_t.untrust; a_t.untrust; empty_t.untrust - - hello_t.gsub(/./, a).should.untrusted? - hello_t.gsub(/./, empty).should.untrusted? - - hello.gsub(/./, a_t).should.untrusted? - hello.gsub(/./, empty_t).should.untrusted? - hello.gsub(//, empty_t).should.untrusted? - - hello.gsub(//.untrust, "foo").should_not.untrusted? - end - end - it "tries to convert pattern to a string using to_str" do pattern = mock('.') def pattern.to_str() "." end @@ -336,28 +292,6 @@ describe "String#gsub with pattern and Hash" do repl = '\& \0 \1 \` \\\' \+ \\\\ foo' "hello".gsub(/(.+)/, 'hello' => repl ).should == repl end - - ruby_version_is ''...'2.7' do - it "untrusts the result if the original string is untrusted" do - str = "Ghana".untrust - str.gsub(/[Aa]na/, 'ana' => '').untrusted?.should be_true - end - - it "untrusts the result if a hash value is untrusted" do - str = "Ghana" - str.gsub(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true - end - - it "taints the result if the original string is tainted" do - str = "Ghana".taint - str.gsub(/[Aa]na/, 'ana' => '').tainted?.should be_true - end - - it "taints the result if a hash value is tainted" do - str = "Ghana" - str.gsub(/a$/, 'a' => 'di'.taint).tainted?.should be_true - end - end end describe "String#gsub! with pattern and Hash" do @@ -426,28 +360,6 @@ describe "String#gsub! with pattern and Hash" do repl = '\& \0 \1 \` \\\' \+ \\\\ foo' "hello".gsub!(/(.+)/, 'hello' => repl ).should == repl end - - ruby_version_is ''...'2.7' do - it "keeps untrusted state" do - str = "Ghana".untrust - str.gsub!(/[Aa]na/, 'ana' => '').untrusted?.should be_true - end - - it "untrusts self if a hash value is untrusted" do - str = "Ghana" - str.gsub!(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true - end - - it "keeps tainted state" do - str = "Ghana".taint - str.gsub!(/[Aa]na/, 'ana' => '').tainted?.should be_true - end - - it "taints self if a hash value is tainted" do - str = "Ghana" - str.gsub!(/a$/, 'a' => 'di'.taint).tainted?.should be_true - end - end end describe "String#gsub with pattern and block" do @@ -526,28 +438,6 @@ describe "String#gsub with pattern and block" do "hello".gsub(/.+/) { obj }.should == "ok" end - ruby_version_is ''...'2.7' do - it "untrusts the result if the original string or replacement is untrusted" do - hello = "hello" - hello_t = "hello" - a = "a" - a_t = "a" - empty = "" - empty_t = "" - - hello_t.untrust; a_t.untrust; empty_t.untrust - - hello_t.gsub(/./) { a }.should.untrusted? - hello_t.gsub(/./) { empty }.should.untrusted? - - hello.gsub(/./) { a_t }.should.untrusted? - hello.gsub(/./) { empty_t }.should.untrusted? - hello.gsub(//) { empty_t }.should.untrusted? - - hello.gsub(//.untrust) { "foo" }.should_not.untrusted? - end - end - it "uses the compatible encoding if they are compatible" do s = "hello" s2 = "#{195.chr}#{192.chr}#{195.chr}" @@ -615,20 +505,6 @@ describe "String#gsub! with pattern and replacement" do a.should == "*¿** **é*?*" end - ruby_version_is ''...'2.7' do - it "taints self if replacement is tainted" do - a = "hello" - a.gsub!(/./.taint, "foo").should_not.tainted? - a.gsub!(/./, "foo".taint).should.tainted? - end - - it "untrusts self if replacement is untrusted" do - a = "hello" - a.gsub!(/./.untrust, "foo").should_not.untrusted? - a.gsub!(/./, "foo".untrust).should.untrusted? - end - end - it "returns nil if no modifications were made" do a = "hello" a.gsub!(/z/, '*').should == nil @@ -654,20 +530,6 @@ describe "String#gsub! with pattern and block" do a.should == "h*ll*" end - ruby_version_is ''...'2.7' do - it "taints self if block's result is tainted" do - a = "hello" - a.gsub!(/./.taint) { "foo" }.should_not.tainted? - a.gsub!(/./) { "foo".taint }.should.tainted? - end - - it "untrusts self if block's result is untrusted" do - a = "hello" - a.gsub!(/./.untrust) { "foo" }.should_not.untrusted? - a.gsub!(/./) { "foo".untrust }.should.untrusted? - end - end - it "returns nil if no modifications were made" do a = "hello" a.gsub!(/z/) { '*' }.should == nil diff --git a/spec/ruby/core/string/insert_spec.rb b/spec/ruby/core/string/insert_spec.rb index 752cbb2f37..db42a37941 100644 --- a/spec/ruby/core/string/insert_spec.rb +++ b/spec/ruby/core/string/insert_spec.rb @@ -41,18 +41,6 @@ describe "String#insert with index, other" do "abcd".insert(-3, other).should == "abXYZcd" end - ruby_version_is ''...'2.7' do - it "taints self if string to insert is tainted" do - str = "abcd" - str.insert(0, "T".taint).should.tainted? - - str = "abcd" - other = mock('T') - def other.to_str() "T".taint end - str.insert(0, other).should.tainted? - end - end - it "raises a TypeError if other can't be converted to string" do -> { "abcd".insert(-6, Object.new)}.should raise_error(TypeError) -> { "abcd".insert(-6, []) }.should raise_error(TypeError) diff --git a/spec/ruby/core/string/inspect_spec.rb b/spec/ruby/core/string/inspect_spec.rb index 98b5b32b61..8bfd465144 100644 --- a/spec/ruby/core/string/inspect_spec.rb +++ b/spec/ruby/core/string/inspect_spec.rb @@ -3,18 +3,6 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' describe "String#inspect" do - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "foo".taint.inspect.should.tainted? - "foo\n".taint.inspect.should.tainted? - end - - it "untrusts the result if self is untrusted" do - "foo".untrust.inspect.should.untrusted? - "foo\n".untrust.inspect.should.untrusted? - end - end - it "does not return a subclass instance" do StringSpecs::MyString.new.inspect.should be_an_instance_of(String) end diff --git a/spec/ruby/core/string/ljust_spec.rb b/spec/ruby/core/string/ljust_spec.rb index 0c3b2a2f44..9a25d3abd4 100644 --- a/spec/ruby/core/string/ljust_spec.rb +++ b/spec/ruby/core/string/ljust_spec.rb @@ -31,16 +31,6 @@ describe "String#ljust with length, padding" do "radiology".ljust(8, '-').should == "radiology" end - ruby_version_is ''...'2.7' do - it "taints result when self or padstr is tainted" do - "x".taint.ljust(4).should.tainted? - "x".taint.ljust(0).should.tainted? - "".taint.ljust(0).should.tainted? - "x".taint.ljust(4, "*").should.tainted? - "x".ljust(4, "*".taint).should.tainted? - end - end - it "tries to convert length to an integer using to_int" do "^".ljust(3.8, "_^").should == "^_^" @@ -96,14 +86,6 @@ describe "String#ljust with length, padding" do end end - ruby_version_is ''...'2.7' do - it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do - "hello".ljust(4, 'X'.taint).tainted?.should be_false - "hello".ljust(5, 'X'.taint).tainted?.should be_false - "hello".ljust(6, 'X'.taint).tainted?.should be_true - end - end - describe "with width" do it "returns a String in the same encoding as the original" do str = "abc".force_encoding Encoding::IBM437 diff --git a/spec/ruby/core/string/lstrip_spec.rb b/spec/ruby/core/string/lstrip_spec.rb index 8b5dd1b467..6e868eac4f 100644 --- a/spec/ruby/core/string/lstrip_spec.rb +++ b/spec/ruby/core/string/lstrip_spec.rb @@ -18,14 +18,6 @@ describe "String#lstrip" do "\000 \000hello\000 \000".lstrip.should == "hello\000 \000" end end - - ruby_version_is ''...'2.7' do - it "taints the result when self is tainted" do - "".taint.lstrip.should.tainted? - "ok".taint.lstrip.should.tainted? - " ok".taint.lstrip.should.tainted? - end - end end describe "String#lstrip!" do diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb index dc11ced4e2..99c1694417 100644 --- a/spec/ruby/core/string/modulo_spec.rb +++ b/spec/ruby/core/string/modulo_spec.rb @@ -302,29 +302,6 @@ describe "String#%" do end end - ruby_version_is ''...'2.7' do - it "always taints the result when the format string is tainted" do - universal = mock('0') - def universal.to_int() 0 end - def universal.to_str() "0" end - def universal.to_f() 0.0 end - - [ - "", "foo", - "%b", "%B", "%c", "%d", "%e", "%E", - "%f", "%g", "%G", "%i", "%o", "%p", - "%s", "%u", "%x", "%X" - ].each do |format| - subcls_format = StringSpecs::MyString.new(format) - subcls_format.taint - format.taint - - (format % universal).should.tainted? - (subcls_format % universal).should.tainted? - end - end - end - it "supports binary formats using %b for positive numbers" do ("%b" % 10).should == "1010" ("% b" % 10).should == " 1010" @@ -578,20 +555,6 @@ describe "String#%" do # ("%p" % obj).should == "obj" end - ruby_version_is ''...'2.7' do - it "taints result for %p when argument.inspect is tainted" do - obj = mock('x') - def obj.inspect() "x".taint end - - ("%p" % obj).should.tainted? - - obj = mock('x'); obj.taint - def obj.inspect() "x" end - - ("%p" % obj).should_not.tainted? - end - end - it "supports string formats using %s" do ("%s" % "hello").should == "hello" ("%s" % "").should == "" @@ -620,13 +583,6 @@ describe "String#%" do # ("%s" % obj).should == "obj" end - ruby_version_is ''...'2.7' do - it "taints result for %s when argument is tainted" do - ("%s" % "x".taint).should.tainted? - ("%s" % mock('x').taint).should.tainted? - end - end - # MRI crashes on this one. # See http://groups.google.com/group/ruby-core-google/t/c285c18cd94c216d it "raises an ArgumentError for huge precisions for %s" do @@ -786,12 +742,6 @@ describe "String#%" do it "behaves as if calling Kernel#Float for #{format} arguments, when the passed argument is hexadecimal string" do (format % "0xA").should == (format % 0xA) end - - ruby_version_is ''...'2.7' do - it "doesn't taint the result for #{format} when argument is tainted" do - (format % "5".taint).should_not.tainted? - end - end end describe "when format string contains %{} sections" do diff --git a/spec/ruby/core/string/plus_spec.rb b/spec/ruby/core/string/plus_spec.rb index 9f0db6427c..5ff198f07e 100644 --- a/spec/ruby/core/string/plus_spec.rb +++ b/spec/ruby/core/string/plus_spec.rb @@ -32,18 +32,5 @@ describe "String#+" do ("hello" + StringSpecs::MyString.new("")).should be_an_instance_of(String) end - ruby_version_is ''...'2.7' do - it "taints the result when self or other is tainted" do - strs = ["", "OK", StringSpecs::MyString.new(""), StringSpecs::MyString.new("OK")] - strs += strs.map { |s| s.dup.taint } - - strs.each do |str| - strs.each do |other| - (str + other).tainted?.should == (str.tainted? | other.tainted?) - end - end - end - end - it_behaves_like :string_concat_encoding, :+ end diff --git a/spec/ruby/core/string/prepend_spec.rb b/spec/ruby/core/string/prepend_spec.rb index a6074be3c6..a0393d4760 100644 --- a/spec/ruby/core/string/prepend_spec.rb +++ b/spec/ruby/core/string/prepend_spec.rb @@ -34,16 +34,6 @@ describe "String#prepend" do a.should == "hello world" end - ruby_version_is ''...'2.7' do - it "taints self if other is tainted" do - x = "x" - x.prepend("".taint).tainted?.should be_true - - x = "x" - x.prepend("y".taint).tainted?.should be_true - end - end - it "takes multiple arguments" do str = " world" str.prepend "he", "", "llo" diff --git a/spec/ruby/core/string/reverse_spec.rb b/spec/ruby/core/string/reverse_spec.rb index b45ff2cf6f..bade4685d9 100644 --- a/spec/ruby/core/string/reverse_spec.rb +++ b/spec/ruby/core/string/reverse_spec.rb @@ -26,13 +26,6 @@ describe "String#reverse" do end end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "".taint.reverse.should.tainted? - "m".taint.reverse.should.tainted? - end - end - it "reverses a string with multi byte characters" do "微軟正黑體".reverse.should == "體黑正軟微" end diff --git a/spec/ruby/core/string/rjust_spec.rb b/spec/ruby/core/string/rjust_spec.rb index f51aacff44..d067b7bdb3 100644 --- a/spec/ruby/core/string/rjust_spec.rb +++ b/spec/ruby/core/string/rjust_spec.rb @@ -31,16 +31,6 @@ describe "String#rjust with length, padding" do "radiology".rjust(8, '-').should == "radiology" end - ruby_version_is ''...'2.7' do - it "taints result when self or padstr is tainted" do - "x".taint.rjust(4).should.tainted? - "x".taint.rjust(0).should.tainted? - "".taint.rjust(0).should.tainted? - "x".taint.rjust(4, "*").should.tainted? - "x".rjust(4, "*".taint).should.tainted? - end - end - it "tries to convert length to an integer using to_int" do "^".rjust(3.8, "^_").should == "^_^" @@ -96,14 +86,6 @@ describe "String#rjust with length, padding" do end end - ruby_version_is ''...'2.7' do - it "when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self" do - "hello".rjust(4, 'X'.taint).tainted?.should be_false - "hello".rjust(5, 'X'.taint).tainted?.should be_false - "hello".rjust(6, 'X'.taint).tainted?.should be_true - end - end - describe "with width" do it "returns a String in the same encoding as the original" do str = "abc".force_encoding Encoding::IBM437 diff --git a/spec/ruby/core/string/rstrip_spec.rb b/spec/ruby/core/string/rstrip_spec.rb index a1453f91fe..2dc55182ae 100644 --- a/spec/ruby/core/string/rstrip_spec.rb +++ b/spec/ruby/core/string/rstrip_spec.rb @@ -16,14 +16,6 @@ describe "String#rstrip" do it "returns a copy of self with all trailing whitespace and NULL bytes removed" do "\x00 \x00hello\x00 \x00".rstrip.should == "\x00 \x00hello" end - - ruby_version_is ''...'2.7' do - it "taints the result when self is tainted" do - "".taint.rstrip.should.tainted? - "ok".taint.rstrip.should.tainted? - "ok ".taint.rstrip.should.tainted? - end - end end describe "String#rstrip!" do diff --git a/spec/ruby/core/string/scan_spec.rb b/spec/ruby/core/string/scan_spec.rb index 5f86dbbecc..ab73f5747b 100644 --- a/spec/ruby/core/string/scan_spec.rb +++ b/spec/ruby/core/string/scan_spec.rb @@ -65,28 +65,6 @@ describe "String#scan" do -> { "cruel world".scan(mock('x')) }.should raise_error(TypeError) end - ruby_version_is ''...'2.7' do - it "taints the results if the String argument is tainted" do - a = "hello hello hello".scan("hello".taint) - a.each { |m| m.tainted?.should be_true } - end - - it "taints the results when passed a String argument if self is tainted" do - a = "hello hello hello".taint.scan("hello") - a.each { |m| m.tainted?.should be_true } - end - - it "taints the results if the Regexp argument is tainted" do - a = "hello".scan(/./.taint) - a.each { |m| m.tainted?.should be_true } - end - - it "taints the results when passed a Regexp argument if self is tainted" do - a = "hello".taint.scan(/./) - a.each { |m| m.tainted?.should be_true } - end - end - # jruby/jruby#5513 it "does not raise any errors when passed a multi-byte string" do "あああaaaあああ".scan("あああ").should == ["あああ", "あああ"] @@ -173,24 +151,6 @@ describe "String#scan with pattern and block" do $~.should == nil end - ruby_version_is ''...'2.7' do - it "taints the results if the String argument is tainted" do - "hello hello hello".scan("hello".taint).each { |m| m.tainted?.should be_true } - end - - it "taints the results when passed a String argument if self is tainted" do - "hello hello hello".taint.scan("hello").each { |m| m.tainted?.should be_true } - end - - it "taints the results if the Regexp argument is tainted" do - "hello".scan(/./.taint).each { |m| m.tainted?.should be_true } - end - - it "taints the results when passed a Regexp argument if self is tainted" do - "hello".taint.scan(/./).each { |m| m.tainted?.should be_true } - end - end - it "passes block arguments as individual arguments when blocks are provided" do "a b c\na b c\na b c".scan(/(\w*) (\w*) (\w*)/) do |first,second,third| first.should == 'a'; diff --git a/spec/ruby/core/string/shared/chars.rb b/spec/ruby/core/string/shared/chars.rb index 1f045e4530..e9fdf89fd6 100644 --- a/spec/ruby/core/string/shared/chars.rb +++ b/spec/ruby/core/string/shared/chars.rb @@ -63,18 +63,4 @@ describe :string_chars, shared: true do [0xA2].pack('C').force_encoding('SJIS') ] end - - ruby_version_is ''...'2.7' do - it "taints resulting strings when self is tainted" do - str = "hello" - - str.send(@method) do |x| - x.should_not.tainted? - end - - str.dup.taint.send(@method) do |x| - x.should.tainted? - end - end - end end diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb index d6ffad7d4d..54ac1035d3 100644 --- a/spec/ruby/core/string/shared/concat.rb +++ b/spec/ruby/core/string/shared/concat.rb @@ -39,18 +39,6 @@ describe :string_concat, shared: true do str.should be_an_instance_of(StringSpecs::MyString) end - ruby_version_is ''...'2.7' do - it "taints self if other is tainted" do - "x".send(@method, "".taint).should.tainted? - "x".send(@method, "y".taint).should.tainted? - end - - it "untrusts self if other is untrusted" do - "x".send(@method, "".untrust).should.untrusted? - "x".send(@method, "y".untrust).should.untrusted? - end - end - describe "with Integer" do it "concatenates the argument interpreted as a codepoint" do b = "".send(@method, 33) diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb index f9c910596a..bfedf8f35a 100644 --- a/spec/ruby/core/string/shared/each_line.rb +++ b/spec/ruby/core/string/shared/each_line.rb @@ -40,14 +40,6 @@ describe :string_each_line, shared: true do b.should == ["foo\n", "🤡🤡🤡🤡🤡🤡🤡\n", "bar\n", "baz\n"] end - ruby_version_is ''...'2.7' do - it "taints substrings that are passed to the block if self is tainted" do - "one\ntwo\r\nthree".taint.send(@method) { |s| s.should.tainted? } - - "x.y.".send(@method, ".".taint) { |s| s.should_not.tainted? } - end - end - it "passes self as a whole to the block if the separator is nil" do a = [] "one\ntwo\r\nthree".send(@method, nil) { |s| a << s } diff --git a/spec/ruby/core/string/shared/replace.rb b/spec/ruby/core/string/shared/replace.rb index 8dfac49f02..a5108d9e7c 100644 --- a/spec/ruby/core/string/shared/replace.rb +++ b/spec/ruby/core/string/shared/replace.rb @@ -10,36 +10,6 @@ describe :string_replace, shared: true do a.should == "another string" end - ruby_version_is ''...'2.7' do - it "taints self if other is tainted" do - a = "" - b = "".taint - a.send(@method, b) - a.should.tainted? - end - - it "does not untaint self if other is untainted" do - a = "".taint - b = "" - a.send(@method, b) - a.should.tainted? - end - - it "untrusts self if other is untrusted" do - a = "" - b = "".untrust - a.send(@method, b) - a.should.untrusted? - end - - it "does not trust self if other is trusted" do - a = "".untrust - b = "" - a.send(@method, b) - a.should.untrusted? - end - end - it "replaces the encoding of self with that of other" do a = "".encode("UTF-16LE") b = "".encode("UTF-8") diff --git a/spec/ruby/core/string/shared/slice.rb b/spec/ruby/core/string/shared/slice.rb index 1db8fd6730..228af5f824 100644 --- a/spec/ruby/core/string/shared/slice.rb +++ b/spec/ruby/core/string/shared/slice.rb @@ -80,17 +80,6 @@ describe :string_slice_index_length, shared: true do "hello there".send(@method, -3,2).should == "er" end - ruby_version_is ''...'2.7' do - it "always taints resulting strings when self is tainted" do - str = "hello world" - str.taint - - str.send(@method, 0,0).should.tainted? - str.send(@method, 0,1).should.tainted? - str.send(@method, 2,1).should.tainted? - end - end - it "returns a string with the same encoding" do s = "hello there" s.send(@method, 1, 9).encoding.should == s.encoding @@ -249,20 +238,6 @@ describe :string_slice_range, shared: true do "x".send(@method, 1...-1).should == "" end - ruby_version_is ''...'2.7' do - it "always taints resulting strings when self is tainted" do - str = "hello world" - str.taint - - str.send(@method, 0..0).should.tainted? - str.send(@method, 0...0).should.tainted? - str.send(@method, 0..1).should.tainted? - str.send(@method, 0...1).should.tainted? - str.send(@method, 2..3).should.tainted? - str.send(@method, 2..0).should.tainted? - end - end - ruby_version_is ''...'3.0' do it "returns subclass instances" do s = StringSpecs::MyString.new("hello") @@ -334,14 +309,12 @@ describe :string_slice_range, shared: true do "hello there".send(@method, eval("(-4...)")).should == "here" end - ruby_version_is "2.7" do - it "works with beginless ranges" do - "hello there".send(@method, eval("(..5)")).should == "hello " - "hello there".send(@method, eval("(...5)")).should == "hello" - "hello there".send(@method, eval("(..-4)")).should == "hello th" - "hello there".send(@method, eval("(...-4)")).should == "hello t" - "hello there".send(@method, eval("(...nil)")).should == "hello there" - end + it "works with beginless ranges" do + "hello there".send(@method, (..5)).should == "hello " + "hello there".send(@method, (...5)).should == "hello" + "hello there".send(@method, (..-4)).should == "hello th" + "hello there".send(@method, (...-4)).should == "hello t" + "hello there".send(@method, (...nil)).should == "hello there" end end @@ -356,26 +329,6 @@ describe :string_slice_regexp, shared: true do end not_supported_on :opal do - 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.send(@method, //).tainted?.should == str.tainted? - str.send(@method, /hello/).tainted?.should == str.tainted? - - tainted_re = /./ - tainted_re.taint - - str.send(@method, tainted_re).should.tainted? - end - end - - it "returns an untrusted string if the regexp is untrusted" do - "hello".send(@method, /./.untrust).untrusted?.should be_true - end - end end ruby_version_is ''...'3.0' do @@ -418,36 +371,6 @@ describe :string_slice_regexp_index, shared: true do "har".send(@method, /(.)(.)(.)/, -3).should == "h" end - 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.send(@method, //, 0).tainted?.should == str.tainted? - str.send(@method, /hello/, 0).tainted?.should == str.tainted? - - str.send(@method, /(.)(.)(.)/, 0).tainted?.should == str.tainted? - str.send(@method, /(.)(.)(.)/, 1).tainted?.should == str.tainted? - str.send(@method, /(.)(.)(.)/, -1).tainted?.should == str.tainted? - str.send(@method, /(.)(.)(.)/, -2).tainted?.should == str.tainted? - - tainted_re = /(.)(.)(.)/ - tainted_re.taint - - str.send(@method, tainted_re, 0).should.tainted? - str.send(@method, tainted_re, 1).should.tainted? - str.send(@method, tainted_re, -1).should.tainted? - end - end - - not_supported_on :opal do - it "returns an untrusted string if the regexp is untrusted" do - "hello".send(@method, /(.)/.untrust, 1).untrusted?.should be_true - end - end - end - it "returns nil if there is no match" do "hello there".send(@method, /(what?)/, 1).should == nil end @@ -510,21 +433,6 @@ describe :string_slice_string, shared: true do "hello there".send(@method, s).should == s end - 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| - strs.each do |other| - r = str.send(@method, other) - - r.tainted?.should == !r.nil? & other.tainted? - end - end - end - end - it "doesn't set $~" do $~ = nil @@ -584,30 +492,6 @@ describe :string_slice_regexp_group, shared: true do "hello there".send(@method, /(?<g>h(?<g>.))/, 'g').should == "e" end - 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.send(@method, /(?<hi>hello)/, 'hi').tainted?.should == str.tainted? - - str.send(@method, /(?<g>(.)(.)(.))/, 'g').tainted?.should == str.tainted? - str.send(@method, /(?<h>.)(.)(.)/, 'h').tainted?.should == str.tainted? - str.send(@method, /(.)(?<a>.)(.)/, 'a').tainted?.should == str.tainted? - str.send(@method, /(.)(.)(?<r>.)/, 'r').tainted?.should == str.tainted? - str.send(@method, /(?<h>.)(?<a>.)(?<r>.)/, 'r').tainted?.should == str.tainted? - - tainted_re = /(?<a>.)(?<b>.)(?<c>.)/ - tainted_re.taint - - str.send(@method, tainted_re, 'a').tainted?.should be_true - str.send(@method, tainted_re, 'b').tainted?.should be_true - str.send(@method, tainted_re, 'c').tainted?.should be_true - end - end - end - it "returns nil if there is no match" do "hello there".send(@method, /(?<whut>what?)/, 'whut').should be_nil end diff --git a/spec/ruby/core/string/shared/succ.rb b/spec/ruby/core/string/shared/succ.rb index 25602103b6..66edf6dc82 100644 --- a/spec/ruby/core/string/shared/succ.rb +++ b/spec/ruby/core/string/shared/succ.rb @@ -74,14 +74,6 @@ describe :string_succ, shared: true do StringSpecs::MyString.new("z").send(@method).should be_an_instance_of(String) end end - - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - ["", "a", "z", "Z", "9", "\xFF", "\xFF\xFF"].each do |s| - s.taint.send(@method).should.tainted? - end - end - end end describe :string_succ_bang, shared: true do diff --git a/spec/ruby/core/string/shared/to_s.rb b/spec/ruby/core/string/shared/to_s.rb index b8c9b8ab44..4b87a6cbe1 100644 --- a/spec/ruby/core/string/shared/to_s.rb +++ b/spec/ruby/core/string/shared/to_s.rb @@ -10,11 +10,4 @@ describe :string_to_s, shared: true do s.should == "a string" s.should be_an_instance_of(String) end - - ruby_version_is ''...'2.7' do - it "taints the result when self is tainted" do - "x".taint.send(@method).should.tainted? - StringSpecs::MyString.new("x").taint.send(@method).should.tainted? - end - end end diff --git a/spec/ruby/core/string/slice_spec.rb b/spec/ruby/core/string/slice_spec.rb index 83b475c8b5..c9e13ed1bc 100644 --- a/spec/ruby/core/string/slice_spec.rb +++ b/spec/ruby/core/string/slice_spec.rb @@ -94,16 +94,6 @@ describe "String#slice! with index, length" do a.should == "h" end - 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).should.tainted? - str.slice!(2, 1).should.tainted? - end - end - it "returns nil if the given position is out of self" do a = "hello" a.slice(10, 3).should == nil @@ -195,16 +185,6 @@ describe "String#slice! Range" do b.should == "hello" end - 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).should.tainted? - str.slice!(2..3).should.tainted? - end - end - ruby_version_is ''...'3.0' do it "returns subclass instances" do s = StringSpecs::MyString.new("hello") @@ -294,30 +274,6 @@ describe "String#slice! with Regexp" do s.should == "this is a string" end - 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? - - tainted_re = /./ - tainted_re.taint - - str.slice!(tainted_re).should.tainted? - end - end - - it "doesn't taint self when regexp is tainted" do - s = "hello" - s.slice!(/./.taint) - s.should_not.tainted? - end - end - ruby_version_is ''...'3.0' do it "returns subclass instances" do s = StringSpecs::MyString.new("hello") @@ -365,30 +321,6 @@ describe "String#slice! with Regexp, index" do str.should == "ho here" end - 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? - - tainted_re = /(.)(.)(.)/ - tainted_re.taint - - str.slice!(tainted_re, 1).should.tainted? - end - end - - it "doesn't taint self when regexp is tainted" do - s = "hello" - s.slice!(/(.)(.)/.taint, 1) - s.should_not.tainted? - end - end - it "returns nil if there was no match" do s = "this is a string" s.slice!(/x(zzz)/, 1).should == nil @@ -463,23 +395,6 @@ describe "String#slice! with String" do c.should == "he hello" end - 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) - - r.tainted?.should == !r.nil? & other.tainted? - end - end - end - end - it "doesn't set $~" do $~ = nil diff --git a/spec/ruby/core/string/split_spec.rb b/spec/ruby/core/string/split_spec.rb index 2da71948b3..82911ef50b 100644 --- a/spec/ruby/core/string/split_spec.rb +++ b/spec/ruby/core/string/split_spec.rb @@ -89,21 +89,19 @@ describe "String#split with String" do end end - ruby_version_is "2.7" do - context "when $; is not nil" do - before do - suppress_warning do - @old_value, $; = $;, 'foobar' - end + context "when $; is not nil" do + before do + suppress_warning do + @old_value, $; = $;, 'foobar' end + end - after do - $; = @old_value - end + after do + $; = @old_value + end - it "warns" do - -> { "".split }.should complain(/warning: \$; is set to non-nil value/) - end + it "warns" do + -> { "".split }.should complain(/warning: \$; is set to non-nil value/) end end end @@ -207,24 +205,6 @@ describe "String#split with String" do end end - ruby_version_is ''...'2.7' do - it "taints the resulting strings if self is tainted" do - ["", "x.y.z.", " x y "].each do |str| - ["", ".", " "].each do |pat| - [-1, 0, 1, 2].each do |limit| - str.dup.taint.split(pat).each do |x| - x.should.tainted? - end - - str.split(pat.dup.taint).each do |x| - x.should_not.tainted? - end - end - end - end - end - end - it "returns an empty array when whitespace is split on whitespace" do " ".split(" ").should == [] " \n ".split(" ").should == [] @@ -426,37 +406,6 @@ describe "String#split with Regexp" do end end - ruby_version_is ''...'2.7' do - it "taints the resulting strings if self is tainted" do - ["", "x:y:z:", " x y "].each do |str| - [//, /:/, /\s+/].each do |pat| - [-1, 0, 1, 2].each do |limit| - str.dup.taint.split(pat, limit).each do |x| - # See the spec below for why the conditional is here - x.tainted?.should be_true unless x.empty? - end - end - end - end - end - - it "taints an empty string if self is tainted" do - ":".taint.split(//, -1).last.tainted?.should be_true - end - - it "doesn't taints the resulting strings if the Regexp is tainted" do - ["", "x:y:z:", " x y "].each do |str| - [//, /:/, /\s+/].each do |pat| - [-1, 0, 1, 2].each do |limit| - str.split(pat.dup.taint, limit).each do |x| - x.tainted?.should be_false - end - end - end - end - end - end - it "retains the encoding of the source string" do ary = "а б в".split encodings = ary.map { |s| s.encoding } diff --git a/spec/ruby/core/string/squeeze_spec.rb b/spec/ruby/core/string/squeeze_spec.rb index 6f75402c9c..5dc12a4247 100644 --- a/spec/ruby/core/string/squeeze_spec.rb +++ b/spec/ruby/core/string/squeeze_spec.rb @@ -54,16 +54,6 @@ describe "String#squeeze" do -> { s.squeeze("^e-b") }.should raise_error(ArgumentError) end - ruby_version_is ''...'2.7' do - it "taints the result when self is tainted" do - "hello".taint.squeeze("e").should.tainted? - "hello".taint.squeeze("a-z").should.tainted? - - "hello".squeeze("e".taint).should_not.tainted? - "hello".squeeze("l".taint).should_not.tainted? - end - end - it "tries to convert each set arg to a string using to_str" do other_string = mock('lo') other_string.should_receive(:to_str).and_return("lo") diff --git a/spec/ruby/core/string/strip_spec.rb b/spec/ruby/core/string/strip_spec.rb index da06862d06..e841db54ce 100644 --- a/spec/ruby/core/string/strip_spec.rb +++ b/spec/ruby/core/string/strip_spec.rb @@ -16,14 +16,6 @@ describe "String#strip" do " \x00 goodbye \x00 ".strip.should == "goodbye" end end - - ruby_version_is ''...'2.7' do - it "taints the result when self is tainted" do - "".taint.strip.should.tainted? - "ok".taint.strip.should.tainted? - " ok ".taint.strip.should.tainted? - end - end end describe "String#strip!" do diff --git a/spec/ruby/core/string/sub_spec.rb b/spec/ruby/core/string/sub_spec.rb index 5ae9a4bbf3..9effe88c27 100644 --- a/spec/ruby/core/string/sub_spec.rb +++ b/spec/ruby/core/string/sub_spec.rb @@ -137,28 +137,6 @@ describe "String#sub with pattern, replacement" do "hello".sub(/./, 'hah\\').should == 'hah\\ello' end - ruby_version_is ''...'2.7' do - it "taints the result if the original string or replacement is tainted" do - hello = "hello" - hello_t = "hello" - a = "a" - a_t = "a" - empty = "" - empty_t = "" - - hello_t.taint; a_t.taint; empty_t.taint - - hello_t.sub(/./, a).should.tainted? - hello_t.sub(/./, empty).should.tainted? - - hello.sub(/./, a_t).should.tainted? - hello.sub(/./, empty_t).should.tainted? - hello.sub(//, empty_t).should.tainted? - - hello.sub(//.taint, "foo").should_not.tainted? - end - end - it "tries to convert pattern to a string using to_str" do pattern = mock('.') pattern.should_receive(:to_str).and_return(".") @@ -297,28 +275,6 @@ describe "String#sub with pattern and block" do obj.should_receive(:to_s).and_return("ok") "hello".sub(/.+/) { obj }.should == "ok" end - - ruby_version_is ''...'2.7' do - it "taints the result if the original string or replacement is tainted" do - hello = "hello" - hello_t = "hello" - a = "a" - a_t = "a" - empty = "" - empty_t = "" - - hello_t.taint; a_t.taint; empty_t.taint - - hello_t.sub(/./) { a }.should.tainted? - hello_t.sub(/./) { empty }.should.tainted? - - hello.sub(/./) { a_t }.should.tainted? - hello.sub(/./) { empty_t }.should.tainted? - hello.sub(//) { empty_t }.should.tainted? - - hello.sub(//.taint) { "foo" }.should_not.tainted? - end - end end describe "String#sub! with pattern, replacement" do @@ -328,14 +284,6 @@ describe "String#sub! with pattern, replacement" do a.should == "h*llo" end - ruby_version_is ''...'2.7' do - it "taints self if replacement is tainted" do - a = "hello" - a.sub!(/./.taint, "foo").should_not.tainted? - a.sub!(/./, "foo".taint).should.tainted? - end - end - it "returns nil if no modifications were made" do a = "hello" a.sub!(/z/, '*').should == nil @@ -378,14 +326,6 @@ describe "String#sub! with pattern and block" do offsets.should == [[1, 2]] end - ruby_version_is ''...'2.7' do - it "taints self if block's result is tainted" do - a = "hello" - a.sub!(/./.taint) { "foo" }.should_not.tainted? - a.sub!(/./) { "foo".taint }.should.tainted? - end - end - it "returns nil if no modifications were made" do a = "hello" a.sub!(/z/) { '*' }.should == nil @@ -471,28 +411,6 @@ describe "String#sub with pattern and Hash" do "hello".sub(/(.+)/, 'hello' => repl ).should == repl end - ruby_version_is ''...'2.7' do - it "untrusts the result if the original string is untrusted" do - str = "Ghana".untrust - str.sub(/[Aa]na/, 'ana' => '').untrusted?.should be_true - end - - it "untrusts the result if a hash value is untrusted" do - str = "Ghana" - str.sub(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true - end - - it "taints the result if the original string is tainted" do - str = "Ghana".taint - str.sub(/[Aa]na/, 'ana' => '').tainted?.should be_true - end - - it "taints the result if a hash value is tainted" do - str = "Ghana" - str.sub(/a$/, 'a' => 'di'.taint).tainted?.should be_true - end - end - end describe "String#sub! with pattern and Hash" do @@ -557,28 +475,6 @@ describe "String#sub! with pattern and Hash" do repl = '\& \0 \1 \` \\\' \+ \\\\ foo' "hello".sub!(/(.+)/, 'hello' => repl ).should == repl end - - ruby_version_is ''...'2.7' do - it "keeps untrusted state" do - str = "Ghana".untrust - str.sub!(/[Aa]na/, 'ana' => '').untrusted?.should be_true - end - - it "untrusts self if a hash value is untrusted" do - str = "Ghana" - str.sub!(/a$/, 'a' => 'di'.untrust).untrusted?.should be_true - end - - it "keeps tainted state" do - str = "Ghana".taint - str.sub!(/[Aa]na/, 'ana' => '').tainted?.should be_true - end - - it "taints self if a hash value is tainted" do - str = "Ghana" - str.sub!(/a$/, 'a' => 'di'.taint).tainted?.should be_true - end - end end describe "String#sub with pattern and without replacement and block" do diff --git a/spec/ruby/core/string/swapcase_spec.rb b/spec/ruby/core/string/swapcase_spec.rb index 32b358607e..417f6c6d8d 100644 --- a/spec/ruby/core/string/swapcase_spec.rb +++ b/spec/ruby/core/string/swapcase_spec.rb @@ -9,13 +9,6 @@ describe "String#swapcase" do "+++---111222???".swapcase.should == "+++---111222???" end - ruby_version_is ''...'2.7' do - it "taints resulting string when self is tainted" do - "".taint.swapcase.should.tainted? - "hello".taint.swapcase.should.tainted? - end - end - describe "full Unicode case mapping" do it "works for all of Unicode with no option" do "äÖü".swapcase.should == "ÄöÜ" diff --git a/spec/ruby/core/string/tr_s_spec.rb b/spec/ruby/core/string/tr_s_spec.rb index c6ad12139e..e1bb20ce35 100644 --- a/spec/ruby/core/string/tr_s_spec.rb +++ b/spec/ruby/core/string/tr_s_spec.rb @@ -57,19 +57,6 @@ describe "String#tr_s" do end end - ruby_version_is ''...'2.7' do - it "taints the result when self is tainted" do - ["h", "hello"].each do |str| - tainted_str = str.dup.taint - - tainted_str.tr_s("e", "a").should.tainted? - - str.tr_s("e".taint, "a").should_not.tainted? - str.tr_s("e", "a".taint).should_not.tainted? - end - end - end - # http://redmine.ruby-lang.org/issues/show/1839 it "can replace a 7-bit ASCII character with a multibyte one" do a = "uber" diff --git a/spec/ruby/core/string/tr_spec.rb b/spec/ruby/core/string/tr_spec.rb index 06be1e6641..72adb9f2eb 100644 --- a/spec/ruby/core/string/tr_spec.rb +++ b/spec/ruby/core/string/tr_spec.rb @@ -69,19 +69,6 @@ describe "String#tr" do end end - ruby_version_is ''...'2.7' do - it "taints the result when self is tainted" do - ["h", "hello"].each do |str| - tainted_str = str.dup.taint - - tainted_str.tr("e", "a").should.tainted? - - str.tr("e".taint, "a").should_not.tainted? - str.tr("e", "a".taint).should_not.tainted? - end - end - end - # http://redmine.ruby-lang.org/issues/show/1839 it "can replace a 7-bit ASCII character with a multibyte one" do a = "uber" diff --git a/spec/ruby/core/string/undump_spec.rb b/spec/ruby/core/string/undump_spec.rb index b990aa25ee..08058d9bd1 100644 --- a/spec/ruby/core/string/undump_spec.rb +++ b/spec/ruby/core/string/undump_spec.rb @@ -3,16 +3,6 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' describe "String#undump" do - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - '"foo"'.taint.undump.should.tainted? - end - - it "untrusts the result if self is untrusted" do - '"foo"'.untrust.undump.should.untrusted? - end - end - it "does not take into account if a string is frozen" do '"foo"'.freeze.undump.should_not.frozen? end diff --git a/spec/ruby/core/string/unpack/p_spec.rb b/spec/ruby/core/string/unpack/p_spec.rb index 3e187d674f..cd48c0523d 100644 --- a/spec/ruby/core/string/unpack/p_spec.rb +++ b/spec/ruby/core/string/unpack/p_spec.rb @@ -18,12 +18,6 @@ describe "String#unpack with format 'P'" do -> { packed.to_sym.to_s.unpack("P5") }.should raise_error(ArgumentError, /no associated pointer/) end - ruby_version_is ''...'2.7' do - it "taints the unpacked string" do - ["hello"].pack("P").unpack("P5").first.tainted?.should be_true - end - end - it "reads as many characters as specified" do ["hello"].pack("P").unpack("P1").should == ["h"] end @@ -47,10 +41,4 @@ describe "String#unpack with format 'p'" do packed.dup.unpack("p").should == ["hello"] -> { packed.to_sym.to_s.unpack("p") }.should raise_error(ArgumentError, /no associated pointer/) end - - ruby_version_is ''...'2.7' do - it "taints the unpacked string" do - ["hello"].pack("p").unpack("p").first.tainted?.should be_true - end - end end diff --git a/spec/ruby/core/string/unpack/shared/taint.rb b/spec/ruby/core/string/unpack/shared/taint.rb index 061a3e26ad..79c7251f01 100644 --- a/spec/ruby/core/string/unpack/shared/taint.rb +++ b/spec/ruby/core/string/unpack/shared/taint.rb @@ -1,83 +1,2 @@ describe :string_unpack_taint, shared: true do - ruby_version_is ''...'2.7' do - it "does not taint returned arrays if given an untainted format string" do - "".unpack(unpack_format(2)).tainted?.should be_false - end - - it "does not taint returned arrays if given a tainted format string" do - format_string = unpack_format(2).dup - format_string.taint - "".unpack(format_string).tainted?.should be_false - end - - it "does not taint returned strings if given an untainted format string" do - "".unpack(unpack_format(2)).any?(&:tainted?).should be_false - end - - it "does not taint returned strings if given a tainted format string" do - format_string = unpack_format(2).dup - format_string.taint - "".unpack(format_string).any?(&:tainted?).should be_false - end - - it "does not taint returned arrays if given an untainted packed string" do - "".unpack(unpack_format(2)).tainted?.should be_false - end - - it "does not taint returned arrays if given a tainted packed string" do - packed_string = "" - packed_string.taint - packed_string.unpack(unpack_format(2)).tainted?.should be_false - end - - it "does not taint returned strings if given an untainted packed string" do - "".unpack(unpack_format(2)).any?(&:tainted?).should be_false - end - - it "taints returned strings if given a tainted packed string" do - packed_string = "" - packed_string.taint - packed_string.unpack(unpack_format(2)).all?(&:tainted?).should be_true - end - - it "does not untrust returned arrays if given an untrusted format string" do - "".unpack(unpack_format(2)).untrusted?.should be_false - end - - it "does not untrust returned arrays if given a untrusted format string" do - format_string = unpack_format(2).dup - format_string.untrust - "".unpack(format_string).untrusted?.should be_false - end - - it "does not untrust returned strings if given an untainted format string" do - "".unpack(unpack_format(2)).any?(&:untrusted?).should be_false - end - - it "does not untrust returned strings if given a untrusted format string" do - format_string = unpack_format(2).dup - format_string.untrust - "".unpack(format_string).any?(&:untrusted?).should be_false - end - - it "does not untrust returned arrays if given an trusted packed string" do - "".unpack(unpack_format(2)).untrusted?.should be_false - end - - it "does not untrust returned arrays if given a untrusted packed string" do - packed_string = "" - packed_string.untrust - packed_string.unpack(unpack_format(2)).untrusted?.should be_false - end - - it "does not untrust returned strings if given an trusted packed string" do - "".unpack(unpack_format(2)).any?(&:untrusted?).should be_false - end - - it "untrusts returned strings if given a untrusted packed string" do - packed_string = "" - packed_string.untrust - packed_string.unpack(unpack_format(2)).all?(&:untrusted?).should be_true - end - end end diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb index 6cf44b4703..b2b34190fe 100644 --- a/spec/ruby/core/string/upcase_spec.rb +++ b/spec/ruby/core/string/upcase_spec.rb @@ -65,14 +65,6 @@ describe "String#upcase" do -> { "abc".upcase(:invalid_option) }.should raise_error(ArgumentError) end - ruby_version_is ''...'2.7' do - it "taints result when self is tainted" do - "".taint.upcase.should.tainted? - "X".taint.upcase.should.tainted? - "x".taint.upcase.should.tainted? - end - end - ruby_version_is ''...'3.0' do it "returns a subclass instance for subclasses" do StringSpecs::MyString.new("fooBAR").upcase.should be_an_instance_of(StringSpecs::MyString) |