bug in REXML escape codes

P

Phlip

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

daz

Phlip said:
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:

http://qurl.net/mz (quod vide)


daz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top