From c4087bcb129535303c53a6a0fffaff36b071174b Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 30 Sep 2010 00:48:01 +0000 Subject: * 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 --- lib/uri/common.rb | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'lib/uri') diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 3f92423b1a..e6f189bdbe 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -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: -- cgit v1.2.3