Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix bug with empty CDATA not being handled in Hash.from_xml

  • Loading branch information...
commit aba149d702e4dcd999ce1b71688ec15b0c637875 1 parent 2450177
Bradley Harris authored
View
3  activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -108,7 +108,8 @@ def typecast_xml_value(value)
raise "can't typecast #{entries.inspect}"
end
end
- elsif value['type'] == 'file' || value["__content__"].present?
+ elsif value['type'] == 'file' ||
+ (value["__content__"] && (value.keys.size == 1 || value["__content__"].present?))
content = value["__content__"]
if parser = ActiveSupport::XmlMini::PARSING[value["type"]]
parser.arity == 1 ? parser.call(content) : parser.call(content, value)
View
4 activesupport/test/core_ext/hash_ext_test.rb
@@ -899,9 +899,9 @@ def test_tag_with_attrs_and_whitespace
end
def test_empty_cdata_from_xml
- xml = "<content><![CDATA[]]></content>"
+ xml = "<data><![CDATA[]]></data>"
- assert_equal "", Hash.from_xml(xml)["content"]
+ assert_equal "", Hash.from_xml(xml)["data"]
end
def test_xsd_like_types_from_xml
Please sign in to comment.
Something went wrong with that request. Please try again.