Bug in REXML escape codes

Rubies:

REXML can't escape & properly:

    require 'test/unit'
    require 'rexml/document'
    include REXML

    class RexmlIssue < Test::Unit::TestCase
        def test_transmitHTMLescapes()
            doc = Document.new('<zone/>')
            zone = XPath.first(doc, '/zone')
            zone.text = '< > &gt;'
            File.open('sample.xml', 'w') {|fh| doc.write(fh) }
            sample = File.read('sample.xml')
            assert_equal '<zone>&lt; &gt; &amp;gt;</zone>', sample
        end
    end

When I feed REXML &gt; in clear text, it does not expand that into
&amp;gt;.

So when we read zone.text back, we get '< > >', not '< > &gt;' again.

I have a patch in my code - I just call a generic escapeHTML() before
stuffing the node's text. But naturally a real fix would be welcome.

···

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand

Phlip wrote:

Rubies:

REXML can't escape & properly:

    require 'test/unit'
    require 'rexml/document'
    include REXML

    class RexmlIssue < Test::Unit::TestCase
        def test_transmitHTMLescapes()
            doc = Document.new('<zone/>')
            zone = XPath.first(doc, '/zone')
            zone.text = '< > &gt;'
            File.open('sample.xml', 'w') {|fh| doc.write(fh) }
            sample = File.read('sample.xml')
            assert_equal '<zone>&lt; &gt; &amp;gt;</zone>', sample
        end
    end

When I feed REXML &gt; in clear text, it does not expand that into
&amp;gt;.

So when we read zone.text back, we get '< > >', not '< > &gt;' again.

I have a patch in my code - I just call a generic escapeHTML() before
stuffing the node's text. But naturally a real fix would be welcome.

This is so like a thread from 11 days ago:

qurl.net - This website is for sale! - qurl Resources and Information. (quod vide)

daz