summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/cgi/test_cgi_util.rb33
1 files changed, 30 insertions, 3 deletions
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb
index b7bb7b8..6ce8b42 100644
--- a/test/cgi/test_cgi_util.rb
+++ b/test/cgi/test_cgi_util.rb
@@ -36,9 +36,7 @@ class CGIUtilTest < Test::Unit::TestCase
end
def test_cgi_escape_with_invalid_byte_sequence
- assert_nothing_raised(ArgumentError) do
- assert_equal('%C0%3C%3C', CGI.escape("\xC0\<\<".dup.force_encoding("UTF-8")))
- end
+ assert_equal('%C0%3C%3C', CGI.escape("\xC0\<\<".dup.force_encoding("UTF-8")))
end
def test_cgi_escape_preserve_encoding
@@ -191,3 +189,32 @@ class CGIUtilTest < Test::Unit::TestCase
assert_equal('&lt;BR&gt;<A HREF="url"></A>', unescape_element(escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"]))
end
end
+
+class CGIUtilPureRubyTest < Test::Unit::TestCase
+ def setup
+ CGI::Escape.module_eval do
+ alias _escapeHTML escapeHTML
+ remove_method :escapeHTML
+ alias _unescapeHTML unescapeHTML
+ remove_method :unescapeHTML
+ end
+ end
+
+ def teardown
+ CGI::Escape.module_eval do
+ alias escapeHTML _escapeHTML
+ remove_method :_escapeHTML
+ alias unescapeHTML _unescapeHTML
+ remove_method :_unescapeHTML
+ end
+ end
+
+ def test_cgi_escapeHTML_with_invalid_byte_sequence
+ assert_equal("&lt;\xA4??&gt;", CGI.escapeHTML(%[<\xA4??>]))
+ end
+
+ def test_cgi_unescapeHTML_with_invalid_byte_sequence
+ input = "\xFF&"
+ assert_equal(input, CGI.unescapeHTML(input))
+ end
+end