aboutsummaryrefslogtreecommitdiffstats
path: root/test/uri/test_common.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-21 12:36:14 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-21 12:36:14 +0000
commit83c2f60b88c73337bcb2fa86228974bddb95f2c8 (patch)
tree9127577263feb943ceb2ab3292ddb15c7e5eebd0 /test/uri/test_common.rb
parent66390013a1eb01c7159412e673965093f05f8161 (diff)
downloadruby-83c2f60b88c73337bcb2fa86228974bddb95f2c8.tar.gz
* lib/uri/common.rb (URI.encode_www_form_component):
convert strings of HTML5 ASCII incompatible encoding to UTF-8. * lib/uri/common.rb (URI.encode_www_form_component): "\x83\x41" of Shift_JIS should be encoded as "%83A". This follows real implementations. * lib/uri/common.rb (URI.decode_www_form_component): use given encoding for force_encoding. [ruby-dev:40721] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/uri/test_common.rb')
-rw-r--r--test/uri/test_common.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb
index 730210e8b3..9f39e843d3 100644
--- a/test/uri/test_common.rb
+++ b/test/uri/test_common.rb
@@ -54,12 +54,12 @@ class TestCommon < Test::Unit::TestCase
assert_equal("%00+%21%22%23%24%25%26%27%28%29*%2B%2C-.%2F09%3A%3B%3C%3D%3E%3F%40" \
"AZ%5B%5C%5D%5E_%60az%7B%7C%7D%7E",
URI.encode_www_form_component("\x00 !\"\#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~"))
- assert_equal("%95%41", URI.encode_www_form_component(
+ assert_equal("%95A", URI.encode_www_form_component(
"\x95\x41".force_encoding(Encoding::Shift_JIS)))
- assert_equal("%30%42", URI.encode_www_form_component(
+ assert_equal("%E3%81%82", URI.encode_www_form_component(
"\x30\x42".force_encoding(Encoding::UTF_16BE)))
- assert_equal("%30%42", URI.encode_www_form_component(
- "\x30\x42".force_encoding(Encoding::ISO_2022_JP)))
+ assert_equal("%1B%24B%24%22%1B%28B", URI.encode_www_form_component(
+ "\e$B$\"\e(B".force_encoding(Encoding::ISO_2022_JP)))
end
def test_decode_www_form_component
@@ -67,6 +67,8 @@ class TestCommon < Test::Unit::TestCase
URI.decode_www_form_component(
"%20+%21%22%23%24%25%26%27%28%29*%2B%2C-.%2F09%3A%3B%3C%3D%3E%3F%40" \
"AZ%5B%5C%5D%5E_%60az%7B%7C%7D%7E"))
+ assert_equal("\xA1\xA2".force_encoding(Encoding::EUC_JP),
+ URI.decode_www_form_component("%A1%A2", "EUC-JP"))
end
def test_encode_www_form