diff options
author | flosacca <[email protected]> | 2023-11-28 04:22:31 +0800 |
---|---|---|
committer | git <[email protected]> | 2023-11-30 08:19:28 +0000 |
commit | 0daa0589a9b714201a9460fef1bcf5260bc3c6ae (patch) | |
tree | 326479f9c4880bf7f2a58e2a6414d7d974c794fe /test/cgi | |
parent | f2f91396576146f58ec299a6d8e5acf665493aa9 (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.rb | 18 |
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('&<&>"&abcdefghijklmn', CGI.unescapeHTML('&<&>"&abcdefghijklmn')) end + module UnescapeHTMLTests + def test_cgi_unescapeHTML_following_known_first_letter + assert_equal('&a>&q>&l>&g>', CGI.unescapeHTML('&a>&q>&l>&g>')) + end + + def test_cgi_unescapeHTML_following_number_sign + assert_equal('&#>&#x>', CGI.unescapeHTML('&#>&#x>')) + end + + def test_cgi_unescapeHTML_following_invalid_numeric + assert_equal('�>�>', CGI.unescapeHTML('�>�>')) + end + end + + include UnescapeHTMLTests + Encoding.list.each do |enc| begin escaped = "'&"><".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("<\xA4??>", CGI.escapeHTML(%[<\xA4??>])) end |