Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10218 (reopened defect)

Opened 2 years ago

Last modified 2 years ago

conversions.rb fails to parse arrays with namespace declaratioins.

Reported by: iasandcb Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveSupport Version: edge
Severity: normal Keywords:
Cc:

Description

conversions.rb fails to parse

<pages xmlns="http://api.springnote.com" type="array"/>

since xmlns="http://api.springnote.com" is translated into entries and falls into "can't typecast http://api.springnote.com". It should return [] just like entries.nil in case that attributes are namespace declarations.

Replacing

if entries.nil?

[]

with

if entries.nil? child_key == 'xmlns' child_key =~ /xmlns:.+/

[]

in "def typecast_xml_value(value)" method (around 174 line)

fixes this problem.

Attachments

namespace_fix.diff (0.7 kB) - added by iasandcb on 11/23/07 05:02:16.
A patch for the description
namespace_test.rb (415 bytes) - added by iasandcb on 12/07/07 04:34:57.
A new test which works locally as well.

Change History

11/23/07 05:02:16 changed by iasandcb

  • attachment namespace_fix.diff added.

A patch for the description

11/24/07 18:34:10 changed by josh

  • status changed from new to closed.
  • resolution set to untested.

Can you please supply a test case along with the patch. Once you've fixed it, please reopen the ticket.

11/25/07 06:53:54 changed by iasandcb

  • status changed from closed to reopened.
  • resolution deleted.

11/26/07 01:20:48 changed by iasandcb

The current patch is different from what the description says.

Instead of replacing if entries.nil?,

replace

child_key, entries = value.detect { |k,v| k != 'type' }

with

child_key, entries = value.detect { |k,v| k != 'type' && k != 'xmlns' && k !=~ /xmlns:.+/ }

12/07/07 04:34:57 changed by iasandcb

  • attachment namespace_test.rb added.

A new test which works locally as well.

12/07/07 04:37:34 changed by iasandcb

OK, now the attached test case does not use a remote resource. Please evaluate it. I hope this issue would be resolved before Rails 2.0 is officially out as SpringBook (http://springbook.playmaru.net) depends on the patch. Thanks.

12/12/07 01:11:31 changed by iasandcb

One week passed since the offline test case got ready. Thanks for your attention in advance.