This project is archived and is in readonly mode.

#2835 ✓duplicate
David Smalley

LibXML XmlMini parser does not handle cdata

Reported by David Smalley | June 25th, 2009 @ 08:32 AM | in 2.3.6

When using LibXML-ruby as the XmlMini backend, cdata elements do not get parsed correctly into the params hash.

e.g.

<blog>
  <posts type="array">
    <post>
      <title>A blog post</title>
      <source><![CDATA[<h1>A blog post about xml cdata</h1>]]></source>
    </post>
  </posts>
</blog>

Should be mapped into the params hash as:

 {"blog" => {"posts" => [{"post" => {"title" => "A blog post", "source" => "<h1>A blog post about xml cdata</h1>"}}]}}

However, it maps in like this instead:

 {"blog" => {"posts" => [{"post" => {"title" => "A blog post", "source" => {""=>nil}}}]}}

The fix was fairly simple and just involved changing the if statement in 'to_hash' to make sure it checked for text and cdata. In addition, I copied over the nokogiri test suite just to make sure there was some basic test coverage for LibXML ruby and to verify that this fix does indeed work.

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>

Attachments

Referenced by

Pages