This project is archived and is in readonly mode.
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
-
Jeremy Kemper October 22nd, 2009 @ 08:36 PM
- Assigned user set to Jeremy Kemper
- State changed from new to open
- Milestone changed from 2.x to 2.3.6
This breaks the build if libxml is not available. Try uninstalling the gem and running the test suite; it should skip this test.
-
David Smalley October 23rd, 2009 @ 10:39 AM
Actually is has at the top...
begin gem 'libxml-ruby', '>= 1.1.3' rescue Gem::LoadError # Skip nokogiri tests else require 'libxml'
So it does skip the tests if the gem isn't available, I just tried it and it worked.
However, I noticed that a fix for this was committed a few weeks ago so this ticket can be closed: http://github.com/rails/rails/commit/fc46c9b2207c62d4b029c2c891c61f...
-
Jeremy Kemper October 23rd, 2009 @ 11:42 AM
- State changed from open to duplicate
(The libxml require is outside the rescue.)
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
Tags
Referenced by
- 3219 Nokogiri XmlMini backend doesn't properly parse cdata elements https://rails.lighthouseapp.com/projects/8994/tickets/28...