summaryrefslogtreecommitdiff
path: root/test/cgi/test_cgi_util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/cgi/test_cgi_util.rb')
-rw-r--r--test/cgi/test_cgi_util.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb
index 0765249..9c9067a 100644
--- a/test/cgi/test_cgi_util.rb
+++ b/test/cgi/test_cgi_util.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'test/unit'
require 'cgi'
require 'stringio'
@@ -15,7 +15,7 @@ class CGIUtilTest < Test::Unit::TestCase
'REQUEST_METHOD' => 'GET',
'SCRIPT_NAME' => nil,
)
- @str1="&<>\" \xE3\x82\x86\xE3\x82\x93\xE3\x82\x86\xE3\x82\x93"
+ @str1="&<>\" \xE3\x82\x86\xE3\x82\x93\xE3\x82\x86\xE3\x82\x93".dup
@str1.force_encoding("UTF-8") if defined?(::Encoding)
end
@@ -31,14 +31,14 @@ class CGIUtilTest < Test::Unit::TestCase
def test_cgi_escape_with_invalid_byte_sequence
assert_nothing_raised(ArgumentError) do
- assert_equal('%C0%3C%3C', CGI::escape("\xC0\<\<".force_encoding("UTF-8")))
+ assert_equal('%C0%3C%3C', CGI::escape("\xC0\<\<".dup.force_encoding("UTF-8")))
end
end
def test_cgi_escape_preserve_encoding
- assert_equal(Encoding::US_ASCII, CGI::escape("\xC0\<\<".force_encoding("US-ASCII")).encoding)
- assert_equal(Encoding::ASCII_8BIT, CGI::escape("\xC0\<\<".force_encoding("ASCII-8BIT")).encoding)
- assert_equal(Encoding::UTF_8, CGI::escape("\xC0\<\<".force_encoding("UTF-8")).encoding)
+ assert_equal(Encoding::US_ASCII, CGI::escape("\xC0\<\<".dup.force_encoding("US-ASCII")).encoding)
+ assert_equal(Encoding::ASCII_8BIT, CGI::escape("\xC0\<\<".dup.force_encoding("ASCII-8BIT")).encoding)
+ assert_equal(Encoding::UTF_8, CGI::escape("\xC0\<\<".dup.force_encoding("UTF-8")).encoding)
end
def test_cgi_unescape
@@ -51,9 +51,9 @@ class CGIUtilTest < Test::Unit::TestCase
end
def test_cgi_unescape_preserve_encoding
- assert_equal(Encoding::US_ASCII, CGI::unescape("%C0%3C%3C".force_encoding("US-ASCII")).encoding)
- assert_equal(Encoding::ASCII_8BIT, CGI::unescape("%C0%3C%3C".force_encoding("ASCII-8BIT")).encoding)
- assert_equal(Encoding::UTF_8, CGI::unescape("%C0%3C%3C".force_encoding("UTF-8")).encoding)
+ assert_equal(Encoding::US_ASCII, CGI::unescape("%C0%3C%3C".dup.force_encoding("US-ASCII")).encoding)
+ assert_equal(Encoding::ASCII_8BIT, CGI::unescape("%C0%3C%3C".dup.force_encoding("ASCII-8BIT")).encoding)
+ assert_equal(Encoding::UTF_8, CGI::unescape("%C0%3C%3C".dup.force_encoding("UTF-8")).encoding)
end
def test_cgi_unescape_accept_charset
@@ -72,7 +72,7 @@ class CGIUtilTest < Test::Unit::TestCase
end
def test_cgi_escape_html_duplicated
- orig = "Ruby".force_encoding("US-ASCII")
+ orig = "Ruby".dup.force_encoding("US-ASCII")
str = CGI::escapeHTML(orig)
assert_equal(orig, str)
assert_not_same(orig, str)
@@ -90,10 +90,10 @@ class CGIUtilTest < Test::Unit::TestCase
end
def test_cgi_escape_html_preserve_tainted
- assert_not_predicate CGI::escapeHTML("'&\"><"), :tainted?
- assert_predicate CGI::escapeHTML("'&\"><".taint), :tainted?
- assert_not_predicate CGI::escapeHTML("Ruby"), :tainted?
- assert_predicate CGI::escapeHTML("Ruby".taint), :tainted?
+ assert_not_predicate CGI::escapeHTML("'&\"><"), :tainted?
+ assert_predicate CGI::escapeHTML("'&\"><".dup.taint), :tainted?
+ assert_not_predicate CGI::escapeHTML("Ruby"), :tainted?
+ assert_predicate CGI::escapeHTML("Ruby".dup.taint), :tainted?
end
def test_cgi_escape_html_dont_freeze