зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
652ab6d3a5
Коммит
c4087bcb12
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,10 @@
|
|||
Thu Sep 30 09:29:06 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* 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
|
||||
|
||||
Thu Sep 30 09:34:03 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* vm_dump.c (dump_thread): fixed wrong type of return value of
|
||||
|
@ -74,10 +81,10 @@ Mon Sep 27 23:30:34 2010 Koichi Sasada <ko1@atdot.net>
|
|||
Mon Sep 27 15:54:03 2010 URABE Shyouhei <shyouhei@ruby-lang.org>
|
||||
|
||||
* test/net/http/test_https.rb: As always, localhost is not
|
||||
guaranteed to be resolved as 127.0.0.1. But a SSL
|
||||
certificate needs a socket to listen on a specific address
|
||||
where a CN resolves to. On situations where localhost is
|
||||
not 127.0.0.1, these tests are not possible.
|
||||
guaranteed to be resolved as 127.0.0.1. But a SSL
|
||||
certificate needs a socket to listen on a specific address
|
||||
where a CN resolves to. On situations where localhost is
|
||||
not 127.0.0.1, these tests are not possible.
|
||||
|
||||
Mon Sep 27 15:25:05 2010 URABE Shyouhei <shyouhei@ruby-lang.org>
|
||||
|
||||
|
@ -258,7 +265,7 @@ Sun Sep 19 20:37:45 2010 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
|||
|
||||
* Makefile.in (clean-capi, distclean-capi, realclean-capi): ditto.
|
||||
|
||||
* win32/Makefile.sub (clean-capi, distclean-capi, realclean-capi):
|
||||
* win32/Makefile.sub (clean-capi, distclean-capi, realclean-capi):
|
||||
ditto.
|
||||
|
||||
Sun Sep 19 13:44:24 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
@ -734,7 +741,7 @@ Sat Sep 4 10:40:50 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
Sun May 23 17:29:41 2010 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* common.mk (capi): uses a timestamp file to get rid of
|
||||
* common.mk (capi): uses a timestamp file to get rid of
|
||||
generating twice.
|
||||
|
||||
Fri Jun 18 01:33:21 2010 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
|
|
@ -346,7 +346,7 @@ module URI
|
|||
ret[:REL_URI] = rel_uri = "(?:#{net_path}|#{abs_path}|#{rel_path})(?:\\?#{query})?"
|
||||
|
||||
# URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
|
||||
ret[:URI_REF] = uri_ref = "(?:#{abs_uri}|#{rel_uri})?(?:##{fragment})?"
|
||||
ret[:URI_REF] = "(?:#{abs_uri}|#{rel_uri})?(?:##{fragment})?"
|
||||
|
||||
ret[:X_ABS_URI] = "
|
||||
(#{scheme}): (?# 1: scheme)
|
||||
|
@ -797,18 +797,14 @@ module URI
|
|||
#
|
||||
# See URI.encode_www_form_component, URI.decode_www_form
|
||||
def self.encode_www_form(enum)
|
||||
str = nil
|
||||
enum.each do |k,v|
|
||||
if str
|
||||
str << '&'
|
||||
else
|
||||
str = nil.to_s
|
||||
enum.map do |k,v|
|
||||
str = encode_www_form_component(k)
|
||||
if v
|
||||
str << '='
|
||||
str << encode_www_form_component(v)
|
||||
end
|
||||
str << encode_www_form_component(k)
|
||||
str << '='
|
||||
str << encode_www_form_component(v)
|
||||
end
|
||||
str
|
||||
str
|
||||
end.join('&')
|
||||
end
|
||||
|
||||
WFKV_ = '(?:%\h\h|[^%#=;&]+)' # :nodoc:
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче