This project is archived and is in readonly mode.

#3824 ✓resolved
Mark Foster

to_xml generates invalid xml for arrays of namespaced ActiveRecords

Reported by Mark Foster | January 31st, 2010 @ 09:26 AM | in 3.0.2

The problem is similar to the one described in:

https://rails.lighthouseapp.com/projects/8994/tickets/2723-to_xml-g...

That patch applied to a single ActiveRecord with namespaces. It turns out that the same problem occurs in arrays of ActiveRecords with namespaces as well, e. g., those returned by find(:all).

The prior patch fixed options[:root] in to_xml for ActiveRecords . However, if the ActiveRecords are in an array, then the value of options[:root] is set in in activesupport/lib/active_support/core_ext/array/conversions.rb to_xml method and passed in to activemodel/lib/active_model/serializers/xml.rb and it contains invalid xml characters. Since options[:root] is not nil, the prior patch has no effect on correcting the invalid characters in arrays of namespaced ActiveRecords.

This patch strips out the invalid characters for any classes with namespaces from the root set in the array to_xml method.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages