Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > bug in REXML escape codes

Reply
Thread Tools

bug in REXML escape codes

 
 
Phlip
Guest
Posts: n/a
 
      10-31-2005
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

 
Reply With Quote
 
 
 
 
daz
Guest
Posts: n/a
 
      11-01-2005

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:

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


daz



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
REXML::Element.write is deprecated. See REXML::Formatters Phlip Ruby 0 01-15-2008 08:23 PM
How to read strings cantaining escape character from a file and useit as escape sequences? slomo Python 5 12-02-2007 11:39 AM
Virtual Key Codes, Scan Codes and ASCII Codes in C gj_williams2000@yahoo.co.uk C Programming 2 08-20-2005 11:04 AM
rexml error - REXML::Validation Daniel Berger Ruby 2 10-12-2004 04:19 PM
soap4r 1.4.8.1 with REXML 2.7.1 - no REXML::VERSION_MAJOR Damphyr Ruby 2 07-16-2003 09:49 AM



Advertisments