GNOME Bugzilla – Bug 494534
xmlNodeSetContent() behaviour with text nodes
Last modified: 2021-07-05 13:20:49 UTC
Using xmlNodeSetContent() with text nodes and with element nodes i get a different behaviour. With this fragment of C code --- begin C code fragment --- nChild1 = xmlNewChild(nRoot, NULL, BAD_CAST "child1", NULL); nChild2 = xmlNewChild(nRoot, NULL, BAD_CAST "child2", NULL); nText2 = xmlNewText(NULL); xmlAddChild(nChild2, nText2); xmlNodeSetContent(nChild1, BAD_CAST "&"); xmlNodeSetContent(nText2, BAD_CAST "&"); --- end C code fragment --- i obtain the following result --- begin result --- <child1>&</child1> <child2>&amp;</child2> --- end result --- According to the documentation "content" (the second argument of xmlNodeSetContent()) "is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first" I suppose the correct behaviour is with element nodes. Doubt: is correct to use xmlNodeSetContent() with text nodes?
Created attachment 98711 [details] the full C source
Created attachment 98713 [details] the full XML output
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.