From 477f0e798106521865ec7f58026973163a580896 Mon Sep 17 00:00:00 2001 From: Zach Moazeni <zach.moazeni@gmail.com> Date: Wed, 9 Jan 2013 15:02:34 -0500 Subject: [PATCH] Methods that return nil should not be considered YAML This is a direct port of @jaw6's pull request https://github.com/rails/rails/pull/492. His cleanly applied to Rails v3.1 and v3.2, and this cleanly applies to v3.0. With yesterday's security patches http://weblog.rubyonrails.org/2013/1/8/Rails-3-2-11-3-1-10-3-0-19-and-2-3-15-have-been-released/ there is now an issue with Rails v3.0 serving XML to any of the latest versions of ActiveResource. Without this, Rails v3.0 can serve XML to ActiveResource consumers that will see `Hash::DisallowedType: Disallowed type attribute: "yaml"` --- activerecord/test/cases/xml_serialization_test.rb | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/activerecord/test/cases/xml_serialization_test.rb b/activerecord/test/cases/xml_serialization_test.rb index 2003e25..cfbe071 100644 --- a/activerecord/test/cases/xml_serialization_test.rb +++ b/activerecord/test/cases/xml_serialization_test.rb @@ -143,10 +143,7 @@ class NilXmlSerializationTest < ActiveRecord::TestCase end def test_should_serialize_yaml - assert %r{<preferences(.*)></preferences>}.match(@xml) - attributes = $1 - assert_match %r{type="yaml"}, attributes - assert_match %r{nil="true"}, attributes + assert_match %r{<preferences nil=\"true\"></preferences>}, @xml end end -- 1.8.0.1