diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-11-16 19:57:09 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-11-18 23:31:00 -0200 |
commit | 52b71c01fd3c8a87152f55129a8cb3234190734a (patch) | |
tree | cb5bae029d05960767990919ffc95cda003f3b68 /activesupport/lib/active_support/core_ext/object/to_query.rb | |
parent | 07a74f196d6766c09e28ed696debb120a035dde7 (diff) | |
download | rails-52b71c01fd3c8a87152f55129a8cb3234190734a.tar.gz rails-52b71c01fd3c8a87152f55129a8cb3234190734a.tar.bz2 rails-52b71c01fd3c8a87152f55129a8cb3234190734a.zip |
Revert "Quick fix for not escaping []s (not ideal)"
According to http://www.ietf.org/rfc/rfc2616.txt and
http://tools.ietf.org/rfc/rfc3986.txt [ and ] are reserved characters
and should be escaped using "%" HEX HEX
This reverts commit 856d2fd874d72dd9f83204affff4edfef3308361 and
1ee9b40b18a0bed5bb10a0785f7e2730bac983f6..
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/to_query.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/to_query.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/to_query.rb b/activesupport/lib/active_support/core_ext/object/to_query.rb index c9981895b4..3f1540f685 100644 --- a/activesupport/lib/active_support/core_ext/object/to_query.rb +++ b/activesupport/lib/active_support/core_ext/object/to_query.rb @@ -7,7 +7,7 @@ class Object # Note: This method is defined as a default implementation for all Objects for Hash#to_query to work. def to_query(key) require 'cgi' unless defined?(CGI) && defined?(CGI::escape) - "#{CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack('H*') }}=#{CGI.escape(to_param.to_s)}" + "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}" end end @@ -15,7 +15,7 @@ class Array # Converts an array into a string suitable for use as a URL query string, # using the given +key+ as the param name. # - # ['Rails', 'coding'].to_query('hobbies') # => "hobbies[]=Rails&hobbies[]=coding" + # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding" def to_query(key) prefix = "#{key}[]" collect { |value| value.to_query(prefix) }.join '&' |