aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-07-21 05:52:30 +0000
committerRick Olson <technoweenie@gmail.com>2006-07-21 05:52:30 +0000
commit3a0159dd1e66a53d2ee39b3a3625998706cd8ae6 (patch)
tree8b099b4d5fcd1dca2fa13fa76c366d63fdcc78a3
parent291adbd36181ab6766ea2d8f8c0f806c5d8ca422 (diff)
downloadrails-3a0159dd1e66a53d2ee39b3a3625998706cd8ae6.tar.gz
rails-3a0159dd1e66a53d2ee39b3a3625998706cd8ae6.tar.bz2
rails-3a0159dd1e66a53d2ee39b3a3625998706cd8ae6.zip
Strip boolean XML content before checking for 'true' [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4616 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/hash/conversions.rb2
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb4
3 files changed, 5 insertions, 3 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 3d010e7008..4825cdbe6d 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Strip boolean XML content before checking for 'true' [Rick Olson]
+
* Customize default BigDecimal formatting. References #5672 [dave@pragprog.com]
* Correctly convert <foo nil="true"> to nil when using Hash.create_from_xml. [Rick]
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb
index b97c6edeb0..38992f2926 100644
--- a/activesupport/lib/active_support/core_ext/hash/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -95,7 +95,7 @@ module ActiveSupport #:nodoc:
content = translate_xml_entities(value["__content__"])
case value["type"]
when "integer" then content.to_i
- when "boolean" then content == "true"
+ when "boolean" then content.strip == "true"
when "datetime" then ::Time.parse(content).utc
when "date" then ::Date.parse(content)
else content
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index bcb4b43af0..f0a50ec5fe 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -313,7 +313,7 @@ class HashToXmlTest < Test::Unit::TestCase
<title>The First Topic</title>
<author-name>David</author-name>
<id type="integer">1</id>
- <approved type="boolean">false</approved>
+ <approved type="boolean"> true </approved>
<replies-count type="integer">0</replies-count>
<written-on type="date">2003-07-16</written-on>
<viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
@@ -327,7 +327,7 @@ class HashToXmlTest < Test::Unit::TestCase
:title => "The First Topic",
:author_name => "David",
:id => 1,
- :approved => false,
+ :approved => true,
:replies_count => 0,
:written_on => Date.new(2003, 7, 16),
:viewed_at => Time.utc(2003, 7, 16, 9, 28),