GNOME Bugzilla – Bug 131548
xmlWriter produces invalid xml
Last modified: 2009-08-15 18:40:50 UTC
xmlWriter produces invalid output when writing an attribute value with embedded quotes ("). Consider the output of the attached testcase: <?xml version="1.0"?> <root attribute="test"test"/>
Created attachment 23377 [details] testcase
xmlTextWriterWriteAttribute uses xmlTextWriterWriteString to write the attribute content. When in state XML_TEXTWRITER_ATTRIBUTE, xmlTextWriterWriteString uses xmlEncodeSpecialChars to escape characters. From entities.c (xmlEncodeSpecialChars): 628 veillard 1.76 #if 0 629 veillard 1.31 } else if (*cur == '"') { 630 *out++ = '&'; 631 *out++ = 'q'; 632 *out++ = 'u'; 633 *out++ = 'o'; 634 *out++ = 't'; 635 *out++ = ';'; 636 veillard 1.76 #endif And the checkin comment on rev 1.76 says this was done in response to bug 127877.
I extracted the serialization of the attribute content from the routine used elsewhere with the library and changed xmlwriter to use that routine. bill@bbrack bug131548 $ cat test-writer.xml <?xml version="1.0"?> <root attribute="test"test"/> The changes (include/libxml/tree.h, tree.c, xmlwriter.c) are in CVS. Thanks for the report.
This should be closed by release 2.6.6, thanks, Daniel