summaryrefslogtreecommitdiff
path: root/test/cgi
diff options
context:
space:
mode:
authorflosacca <[email protected]>2023-11-28 04:22:31 +0800
committergit <[email protected]>2023-11-30 08:19:28 +0000
commit0daa0589a9b714201a9460fef1bcf5260bc3c6ae (patch)
tree326479f9c4880bf7f2a58e2a6414d7d974c794fe /test/cgi
parentf2f91396576146f58ec299a6d8e5acf665493aa9 (diff)
[ruby/cgi] Add failing test cases for CGI::Escape.unescapeHTML
https://github.com/ruby/cgi/commit/92fdb3316b
Diffstat (limited to 'test/cgi')
-rw-r--r--test/cgi/test_cgi_util.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb
index 1bdc0e4218..b0612fc87d 100644
--- a/test/cgi/test_cgi_util.rb
+++ b/test/cgi/test_cgi_util.rb
@@ -186,6 +186,22 @@ class CGIUtilTest < Test::Unit::TestCase
assert_equal('&<&amp>&quot&abcdefghijklmn', CGI.unescapeHTML('&&lt;&amp&gt;&quot&abcdefghijklmn'))
end
+ module UnescapeHTMLTests
+ def test_cgi_unescapeHTML_following_known_first_letter
+ assert_equal('&a>&q>&l>&g>', CGI.unescapeHTML('&a&gt;&q&gt;&l&gt;&g&gt;'))
+ end
+
+ def test_cgi_unescapeHTML_following_number_sign
+ assert_equal('&#>&#x>', CGI.unescapeHTML('&#&gt;&#x&gt;'))
+ end
+
+ def test_cgi_unescapeHTML_following_invalid_numeric
+ assert_equal('&#1114112>&#x110000>', CGI.unescapeHTML('&#1114112&gt;&#x110000&gt;'))
+ end
+ end
+
+ include UnescapeHTMLTests
+
Encoding.list.each do |enc|
begin
escaped = "&#39;&amp;&quot;&gt;&lt;".encode(enc)
@@ -283,6 +299,8 @@ class CGIUtilPureRubyTest < Test::Unit::TestCase
end if defined?(CGI::Escape)
end
+ include CGIUtilTest::UnescapeHTMLTests
+
def test_cgi_escapeHTML_with_invalid_byte_sequence
assert_equal("&lt;\xA4??&gt;", CGI.escapeHTML(%[<\xA4??>]))
end