GNOME Bugzilla – Bug 159219
replaceEntities replaces the entity twice in character data
Last modified: 2006-10-10 20:07:49 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
Created attachment 34073 [details] Show replaceEntities emits characters() twice with entity content for SAX
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
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