Part of the point of using a library to build up a DOM and output it,
is that all the messy escaping is supposed to be handled under the
covers.
But for this test case:
require 'test/unit'
require 'rexml/text'
include REXML
class TestRexmlEscapes < Test::Unit::TestCase
def test_escape_ampersand
assert_equal "&amp;", Text.new("&").to_s
end
end
Results:
1) Failure:
test_escape_ampersand(TestRexmlEscapes) [test_rexml_escapes.rb:7]:
<"&amp;"> expected but was
<"&">.
In other words, it seems to arbitrarily ignore the "&" which really
needs to be escaped. I didn't ask for :raw at all, and IMO it should
escape everything unless you tell it not to.
It seems like the only workaround for this is to manually escape all
strings correctly and then pass as raw into REXML. But if I'm going to
go to that much trouble, there's really no point in using the library
in the first place as it becomes just as easy to concatenate some
strings together.
Do people consider this to be a real bug?
TX