After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 159219 - replaceEntities replaces the entity twice in character data
replaceEntities replaces the entity twice in character data
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2004-11-23 17:00 UTC by Dave Beckett
Modified: 2006-10-10 20:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Show replaceEntities emits characters() twice with entity content for SAX (1.56 KB, text/plain)
2004-11-23 17:01 UTC, Dave Beckett
Details

Description Dave Beckett 2004-11-23 17:00:02 UTC
Using SAX and setting xc->replaceEntities=1, an entity gets
expanded twice, and emits two characters() callbacks
with the content of the entity.  I expected it to call the acharacters()
callback once.  I'll attach a test program that shows this to this
bug once created.

When the test program compiled:
  gcc -Wall -o test test.c `xml2-config --cflags` `xml2-config --libs`
and run, you get the following:
xmlCreatePushParserCtxt with replaceEntities = 0
SAX.startElement(root, attribute='&foo;')
SAX.characters(   , 3)
SAX.startElement(element)
SAX.characters(def, 3)
----------
xmlCreatePushParserCtxt with replaceEntities = 1
SAX.startElement(root, attribute='abc')
SAX.characters(   , 3)
SAX.startElement(element)
SAX.characters(def, 3)
SAX.characters(def, 3)

The expected output in the last case is to emit only one
  SAX.characters(def, 3)
The first output is for comparison, showing entities are not expanded
in attribute values but are in characters even when replaceEntities=0

Tested against CVS and 2.6.16
Comment 1 Dave Beckett 2004-11-23 17:01:48 UTC
Created attachment 34073 [details]
Show replaceEntities emits characters() twice with entity content for SAX
Comment 2 Eric Seidel 2006-07-27 05:46:44 UTC
WebKit (http://www.webkit.org/) has used a couple different work-arounds for this bug.  The latest is documented here:
http://bugzilla.opendarwin.org/show_bug.cgi?id=6390
Comment 3 Daniel Veillard 2006-10-10 20:07:49 UTC
I finally had the time and energy to try to nail that one, took half
a day messing in the entities handling code but 1/ it seems to work
and 2/ I tried to minimize changes in the SAX events generated

paphio:~/XML -> ./tst
xmlCreatePushParserCtxt with replaceEntities = 0
SAX.startElement(root, attribute='&foo;')
SAX.characters(   , 3)
SAX.startElement(element)
SAX.characters(def, 3)
----------
xmlCreatePushParserCtxt with replaceEntities = 1
SAX.startElement(root, attribute='abc')
SAX.characters(   , 3)
SAX.startElement(element)
SAX.characters(def, 3)
----------
paphio:~/XML ->

  I hope it is fixed, 

   thanks and sorry for the delay :-)

Daniel