REXML Attributes and entities


Maybe I'm missing something, but I'm trying to store a REXML Document to a string, loading it back later. Storing it again. etc...

I've noticed the following problem:

script/console session:

xml ="<root value=" />") => <UNDEFINED> ... </> xml.to_s => "<root value=" /> xml.root.attributes['value'] = '<' xml.root.text = '>' xml.to_s => "<root value='&lt;'>&gt;</root>" # fine by me, no problem...

xml2 = xml.to_s ) xml2.to_s => "<root value='&amp;&lt;'>&gt;</root>

As you can see the root.text node is loaded back correctly... But the attribute root.attributes['value'] is synchronized incorrectly..

REXML version:

  DATE = "2006/335"   VERSION = "3.1.6"

Is this a bug?!? Does somebody have a solution for this?!? Thanks in advance!

I found my Windows Ruby on Rails REXML (1.8.4) installation is working perfectly. It seems a bug in the FreeBSD version which is REXML (1.8.6). I'm trying to submit a bug report to the REXML authors, but the server keeps timing out :frowning:

I also found the solution, there's indeed a bug in REXML (1.8.6)

Change the code at line +/- 291 in text.rb: ( /usr/local/lib/ruby/1.8/ rexml/text.rb ) #copy = copy.gsub( EREFERENCE, '&amp;' ) copy = copy.gsub( "&", "&amp;" )

To copy = copy.gsub( EREFERENCE, '&amp;' ) #copy = copy.gsub( "&", "&amp;" )