summaryrefslogtreecommitdiff
path: root/test/cgi/test_cgi_util.rb
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-20 11:48:52 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-20 11:48:52 +0000
commitce8d368b1ea4d6b97b7493074a0c041f59d5a5c1 (patch)
tree43c87ba9600df0542a24defd54484e9708a9bc54 /test/cgi/test_cgi_util.rb
parent587135e9941306efee72346b0d00c82d8e8574e0 (diff)
* lib/cgi/util.rb (CGI.escape): support a string with invalid byte
sequence. * test/cgi/test_cgi_util.rb (test_cgi_escape_with_invalid_byte_sequence): test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi/test_cgi_util.rb')
-rw-r--r--test/cgi/test_cgi_util.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb
index 71e8bea..f34703e 100644
--- a/test/cgi/test_cgi_util.rb
+++ b/test/cgi/test_cgi_util.rb
@@ -24,6 +24,12 @@ class CGIUtilTest < Test::Unit::TestCase
assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93'.ascii_only?, CGI::escape(@str1).ascii_only?) if defined?(::Encoding)
end
+ 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")))
+ end
+ end
+
def test_cgi_unescape
assert_equal(@str1, CGI::unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93'))
assert_equal(@str1.encoding, CGI::unescape('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93').encoding) if defined?(::Encoding)