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 494534 - xmlNodeSetContent() behaviour with text nodes
xmlNodeSetContent() behaviour with text nodes
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: general
2.6.30
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2007-11-07 10:48 UTC by massimo morara
Modified: 2021-07-05 13:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the full C source (827 bytes, text/x-csrc)
2007-11-07 10:50 UTC, massimo morara
Details
the full XML output (108 bytes, text/xml)
2007-11-07 10:52 UTC, massimo morara
Details

Description massimo morara 2007-11-07 10:48:20 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>&amp;</child1>
  <child2>&amp;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?
Comment 1 massimo morara 2007-11-07 10:50:30 UTC
Created attachment 98711 [details]
the full C source
Comment 2 massimo morara 2007-11-07 10:52:11 UTC
Created attachment 98713 [details]
the full XML output
Comment 3 GNOME Infrastructure Team 2021-07-05 13:20:49 UTC
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.