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.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

LibXML XmlMini parser does not handle cdata

#2835

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.

Reported by David Smalley · June 25th, 2009 @ 08:32 AM

State: duplicate
Milestone: 2.3.6
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Medium

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • 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.

    October 22nd, 2009 @ 08:36 PM

  2. David Smalley
    David Smalley

    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...

    October 23rd, 2009 @ 10:39 AM

  3. Jeremy Kemper
    Jeremy Kemper
    • State changed from open to duplicate

    (The libxml require is outside the rescue.)

    October 23rd, 2009 @ 11:42 AM