summaryrefslogtreecommitdiff
path: root/lib/uri
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-30 00:48:01 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-30 00:48:01 +0000
commitc4087bcb129535303c53a6a0fffaff36b071174b (patch)
treeced6216f7a1fceb6e591edc3359444ac89b7a674 /lib/uri
parent652ab6d3a53a09032f944e58367948c1688aedc9 (diff)
* 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 'lib/uri')
-rw-r--r--lib/uri/common.rb20
1 files changed, 8 insertions, 12 deletions
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: