aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-03-03 22:55:14 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-03-03 22:55:14 +0000
commite4106a580ec5008f7a84be6f412e5d88d7a160cb (patch)
tree2bfa0a1504e9dfdaf223a99329073287cdddb38e /activesupport/lib/active_support
parente834be75bcbbece8970abad221f21411c5b93a96 (diff)
downloadrails-e4106a580ec5008f7a84be6f412e5d88d7a160cb.tar.gz
rails-e4106a580ec5008f7a84be6f412e5d88d7a160cb.tar.bz2
rails-e4106a580ec5008f7a84be6f412e5d88d7a160cb.zip
Fixed an exception when using Ajax based requests from Safari because Safari appends a \000 to the post body. Symbols can't have \000 in them so indifferent access would throw an exception in the constructor. Indifferent hashes now use strings internally instead. #746 [Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@827 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/indifferent_access.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
index 2353cfaf3b..d8594db739 100644
--- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
+++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
@@ -1,8 +1,8 @@
class HashWithIndifferentAccess < Hash
- def initialize(constructor)
+ def initialize(constructor = {})
if constructor.is_a?(Hash)
super()
- update(constructor.symbolize_keys)
+ update(constructor.stringify_keys)
else
super(constructor)
end
@@ -12,7 +12,7 @@ class HashWithIndifferentAccess < Hash
def [](key)
case key
- when Symbol: regular_reader(key) || regular_reader(key.to_s)
+ when Symbol: regular_reader(key.to_s) || regular_reader(key)
when String: regular_reader(key) || regular_reader(key.to_sym)
else regular_reader(key)
end
@@ -21,7 +21,7 @@ class HashWithIndifferentAccess < Hash
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
def []=(key, value)
- regular_writer(key.is_a?(String) ? key.to_sym : key, value)
+ regular_writer(key.is_a?(Symbol) ? key.to_s : key, value)
end
end