From aafaa7a25702e4b48814ee0f2992edad59b95aae Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 6 Feb 2016 13:31:07 +0000 Subject: ASCII-incompatible escape * lib/cgi/util.rb (escapeHTML, unescapeHTML): consider ASCII-incompatible encodings. [Fix GH-1239] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/cgi/test_cgi_util.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb index 5565afe9c1..f67817fce6 100644 --- a/test/cgi/test_cgi_util.rb +++ b/test/cgi/test_cgi_util.rb @@ -98,6 +98,22 @@ class CGIUtilTest < Test::Unit::TestCase assert_equal("'&\"><", CGI::unescapeHTML("'&"><")) end + Encoding.list.each do |enc| + begin + escaped = "'&"><".encode(enc) + unescaped = "'&\"><".encode(enc) + rescue Encoding::ConverterNotFoundError + next + else + define_method("test_cgi_escapeHTML:#{enc.name}") do + assert_equal(escaped, CGI::escapeHTML(unescaped)) + end + define_method("test_cgi_unescapeHTML:#{enc.name}") do + assert_equal(unescaped, CGI::unescapeHTML(escaped)) + end + end + end + def test_cgi_unescapeHTML_uppercasecharacter assert_equal("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86", CGI::unescapeHTML("あいう")) end -- cgit v1.2.3