Ticket #31 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

One unescape too many

Reported by: Sam Ruby <rubys@…> Owned by: anonymous
Priority: normal Milestone: 3.1.4
Component: DOM Version: 3.1.2
Severity: normal Keywords:
Cc: Ruby version: 1.8.2
Operating system: Linux

Description

Here's a test case, contrasting libxml2 and REXML:

require 'test/unit'

class TestCData < Test::Unit::TestCase

  @@data = '<title>AT&amp;T</title>'
  @@xml = "<description><![CDATA[#{@@data}]]></description>"

  def test_libxml2
    require 'xml/libxml'
    parser = XML::Parser.new
    parser.string = @@xml
    doc = parser.parse
    description = doc.root.find("//description").to_a
    assert_equal @@data, description[0].child.content
  end

  def test_rexml
    require 'rexml/document'
    doc = REXML::Document.new(@@xml)
    description = doc.find {|e| e.name=="description"}
    assert_equal @@data, description.text
  end

end

Here's my platform info:

rubys@rubypad:~$ ruby -vrrexml/rexml -e 'p REXML::Version,PLATFORM'
ruby 1.8.2 (2004-12-25) [i686-linux]
"3.1.2.1"
"i686-linux"

Change History

Changed 4 years ago by anonymous

  • owner changed from ser to anonymous
  • status changed from new to assigned

Changed 4 years ago by ser

  • status changed from assigned to closed
  • resolution set to fixed

Fixed by [1173].

This wasn't really a bug, per se... "value" always returns a normalized string, and "value" is the method used to get the text() of an element. However, entities have no meaning in CDATA sections, so in a way it was a bug, since there's no justification for value() to be normalizing the content of CData objects. This behavior has therefore been changed.

The fix will be in milestone:3.1.4

Note: See TracTickets for help on using tickets.