aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/string/gsub_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/gsub_spec.rb')
-rw-r--r--spec/ruby/core/string/gsub_spec.rb138
1 files changed, 0 insertions, 138 deletions
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