-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Methods that return nil should not be considered YAML #8853
Methods that return nil should not be considered YAML #8853
Conversation
It should get a changelog entry, can you please add one? Thanks. |
@carlosantoniodasilva would you want it as a note in a v3.0.20 release in the CHANGELOGs? |
@carlosantoniodasilva Just updated the commit. I only updated the CHANGELOG of activemodel. Let me know if you need anything else! |
Seems fine, I'll just ask you to elaborate the changelog a little bit more with what's actually being fixed (ie the pull request title with minor tweaks seems to describe it better I think). Wdyt? |
Actually I changed the wrong CHANGELOG. Fixing. |
This is a direct port of @jaw6's pull request rails#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"`
@carlosantoniodasilva Alrighty. Updated again. |
Methods that return nil should not be considered YAML
Great, thank you. |
What if I am consuming an active resource api exposed by a rails 2.3.15 application, let's say reading a model which has a serialized attribute? This commit can be ported in lib/active_record/serializers/xml_serializer.rb to fix the problem with nil values, but I've no idea how to work around the serialized field issue. Any ideas? |
FYI monkey-patch: if Rails.version == "3.0.19"
ActiveModel::Serializers::Xml::Serializer::Attribute.class_eval do
def compute_type_with_nil
return if value.nil?
compute_type_without_nil
end
alias_method_chain :compute_type, :nil
end
else
raise "remove this #{__FILE__}"
end |
This is a direct port of @jaw6's pull request
#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"