Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

to_xml generates invalid xml for arrays of namespaced ActiveRecords

#3824

The problem is similar to the one described in:

#2723 to_xml generates invalid xml with namespaced ActiveRecord

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.

Reported by Mark Foster · January 31st, 2010 @ 09:26 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Mark Foster
    Mark Foster
    • Tag set to activerecord, array, class, modules, namespace, patch, to_xml, xml

    Forgot tags on the ticket.

    January 31st, 2010 @ 09:33 AM

  2. Yaroslav Markin
  3. Yaroslav Markin
    Yaroslav Markin
    • Tag set to activerecord, array, bug, patch, to_xml, xml

    January 31st, 2010 @ 11:42 PM

  4. Yaroslav Markin
    Yaroslav Markin
    • Assigned user set to José Valim

    Ping..

    April 10th, 2010 @ 04:17 PM

  5. José Valim
    José Valim
    • State changed from new to duplicate

    April 10th, 2010 @ 04:21 PM

  6. Repository
    Repository
    • State changed from duplicate to resolved

    (from [5850edf104ab1da0f72a43e6717a1270134db293]) Made arrays of ActiveRecords, and any classes, with namespaces convert to valid xml. [#3824 to_xml generates invalid xml for arrays of namespaced ActiveRecords state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/5850edf104ab1da0f72a43e6717a12...

    April 10th, 2010 @ 05:13 PM

  7. José Valim
  8. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM