diff options
| author | xibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-30 05:34:02 +0000 |
|---|---|---|
| committer | xibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-30 05:34:02 +0000 |
| commit | 6b13962f6c8c0b667954ace6bc80df3dcec770c1 (patch) | |
| tree | 421dc7a33bfe1ca30362f58fdc76ed6c352828a2 /test/cgi/test_cgi_util.rb | |
| parent | 3bb239ef82f727a56181d13b29def44c4a19b48d (diff) | |
| download | ruby-6b13962f6c8c0b667954ace6bc80df3dcec770c1.tar.gz ruby-6b13962f6c8c0b667954ace6bc80df3dcec770c1.tar.xz ruby-6b13962f6c8c0b667954ace6bc80df3dcec770c1.zip | |
* lib/cgi/util.rb (CGI::unescape): support encoding option.
* lib/cgi/cookie.rb (CGI::Cookie.parse): fix for the encoded value.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi/test_cgi_util.rb')
| -rw-r--r-- | test/cgi/test_cgi_util.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb new file mode 100644 index 000000000..ec0744ded --- /dev/null +++ b/test/cgi/test_cgi_util.rb @@ -0,0 +1,32 @@ +require 'test/unit' +require 'cgi' +require 'stringio' + + +class CGIUtilTest < Test::Unit::TestCase + + + def setup + ENV['REQUEST_METHOD'] = 'GET' + @str1="&<>\" \xE3\x82\x86\xE3\x82\x93\xE3\x82\x86\xE3\x82\x93" + @str1.force_encoding("UTF-8") if RUBY_VERSION>="1.9" + end + + def teardown + %W[REQUEST_METHOD SCRIPT_NAME].each do |name| + ENV.delete(name) + end + end + + + def test_cgi_escape + assert_equal('%26%3C%3E%22+%E3%82%86%E3%82%93%E3%82%86%E3%82%93', CGI::escape(@str1)) + 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 RUBY_VERSION>="1.9" + 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 RUBY_VERSION>="1.9" + end + +end |
