Ticket #111 (closed defect: duplicate)
Entities in attributes aren't replaced correctly when parsing a string
| Reported by: | gamecreature | Owned by: | ser |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1.8 |
| Component: | DOM | Version: | 3.1.6 |
| Severity: | normal | Keywords: | |
| Cc: | Ruby version: | Other | |
| Operating system: | Other |
Description
Entities in an attribute aren't converted correctly when creating a new document:
#
# Create the object
#
xml = REXML::Document.new("<root />")
xml.root.attributes['test'] = '<'
xml.to_s => "<root test='<' />"
#
# Use the output of this xml to create a new xml (reload saved data)
#
xml2 = REXML::Document.new( xml.to_s )
xml2.to_s => "<root test='&<' />
# I expect "xml2.to_s" to be "<root test='<' />"
The code above worked correctly in REXML 3.1.4
There's no problem with text nodes: <root><</root> works correctly. It only is broken in the attributes!
I think the cause is the code I found at line +/- 291 in text.rb:
#copy = copy.gsub( EREFERENCE, '&' ) copy = copy.gsub( "&", "&" )
I assume the first copy with EREFERENCE should be enabled not the "&" version! I've tried to changed it and it solved my problem!!
Change History
Note: See
TracTickets for help on using
tickets.
