aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-12-02 22:29:34 -0200
committerJosé Valim <jose.valim@gmail.com>2009-12-02 22:29:34 -0200
commit6e55b32e98fcaad82184d2e21ee611a3465e4b20 (patch)
treee316b8ca72f2bef50668c222400a159b36fbc090 /activesupport/lib/active_support
parentc2e97cb410d759f383d29920165abdbf4b70e019 (diff)
parent399909b11c094ab32542d300c72940b1b263b8e6 (diff)
downloadrails-6e55b32e98fcaad82184d2e21ee611a3465e4b20.tar.gz
rails-6e55b32e98fcaad82184d2e21ee611a3465e4b20.tar.bz2
rails-6e55b32e98fcaad82184d2e21ee611a3465e4b20.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/object/to_param.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/object/to_query.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb13
3 files changed, 10 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/to_param.rb b/activesupport/lib/active_support/core_ext/object/to_param.rb
index a5e2260791..7ca763cbad 100644
--- a/activesupport/lib/active_support/core_ext/object/to_param.rb
+++ b/activesupport/lib/active_support/core_ext/object/to_param.rb
@@ -38,7 +38,7 @@ class Hash
# ==== Examples
# { :name => 'David', :nationality => 'Danish' }.to_query # => "name=David&nationality=Danish"
#
- # { :name => 'David', :nationality => 'Danish' }.to_query('user') # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
+ # { :name => 'David', :nationality => 'Danish' }.to_query('user') # => "user[name]=David&user[nationality]=Danish"
def to_param(namespace = nil)
collect do |key, value|
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
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 3f1540f685..c9981895b4 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)}=#{CGI.escape(to_param.to_s)}"
+ "#{CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack('H*') }}=#{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%5B%5D=Rails&hobbies%5B%5D=coding"
+ # ['Rails', 'coding'].to_query('hobbies') # => "hobbies[]=Rails&hobbies[]=coding"
def to_query(key)
prefix = "#{key}[]"
collect { |value| value.to_query(prefix) }.join '&'
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index 2cca4763f4..a2a88eb7df 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -7,11 +7,11 @@ class String
@_rails_html_safe = true
self
end
-
+
def html_safe
dup.html_safe!
end
-
+
alias original_plus +
def +(other)
result = original_plus(other)
@@ -21,7 +21,7 @@ class String
result
end
end
-
+
alias original_concat <<
def <<(other)
result = original_concat(other)
@@ -30,14 +30,15 @@ class String
end
result
end
-
+
+ remove_method :concat
def concat(other)
self << other
end
-
+
private
def also_html_safe?(other)
other.respond_to?(:html_safe?) && other.html_safe?
end
-
+
end \ No newline at end of file