diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-30 00:48:01 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-30 00:48:01 +0000 |
commit | c4087bcb129535303c53a6a0fffaff36b071174b (patch) | |
tree | ced6216f7a1fceb6e591edc3359444ac89b7a674 /test/uri/test_common.rb | |
parent | 652ab6d3a53a09032f944e58367948c1688aedc9 (diff) | |
download | ruby-c4087bcb129535303c53a6a0fffaff36b071174b.tar.gz |
* lib/uri/common.rb (URI.encode_www_form): change treatment of
undefined value in given array as latest internet draft for
application/www-form-urlencoded.
http://tools.ietf.org/html/draft-hoehrmann-urlencoded-01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/uri/test_common.rb')
-rw-r--r-- | test/uri/test_common.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 01381b20e6..410f46bd0b 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -82,6 +82,21 @@ class TestCommon < Test::Unit::TestCase assert_equal(expected, URI.encode_www_form(a: 1, :"\u3042" => "\u6F22")) assert_equal(expected, URI.encode_www_form([["a", "1"], ["\u3042", "\u6F22"]])) assert_equal(expected, URI.encode_www_form([[:a, 1], [:"\u3042", "\u6F22"]])) + + assert_equal('+a+=+1+', URI.encode_www_form([[' a ', ' 1 ']])) + assert_equal('text=x%0Ay', URI.encode_www_form([['text', "x\u000Ay"]])) + assert_equal('constellation=Bo%C3%B6tes', URI.encode_www_form([['constellation', "Bo\u00F6tes"]])) + assert_equal('name=%00value', URI.encode_www_form([['name', "\u0000value"]])) + assert_equal('Cipher=c%3D%28m%5Ee%29%25n', URI.encode_www_form([['Cipher', 'c=(m^e)%n']])) + assert_equal('&', URI.encode_www_form([['', nil], ['', nil]])) + assert_equal('&=', URI.encode_www_form([['', nil], ['', '']])) + assert_equal('=&', URI.encode_www_form([['', ''], ['', nil]])) + assert_equal('=&=', URI.encode_www_form([['', ''], ['', '']])) + assert_equal('', URI.encode_www_form([['', nil]])) + assert_equal('', URI.encode_www_form([])) + assert_equal('=', URI.encode_www_form([['', '']])) + assert_equal('a%26b=1&c=2%3B3&e=4', URI.encode_www_form([['a&b', '1'], ['c', '2;3'], ['e', '4']])) + assert_equal('image&title&price', URI.encode_www_form([['image', nil], ['title', nil], ['price', nil]])) end def test_decode_www_form |