[xml] xmlTextWriter writes invalid xml



Hi,

there seems to be a bug in xmlTextWriter. [I've filed this last week as 
http://bugzilla.gnome.org/show_bug.cgi?id=131548 , but since it hasn't
received a response yet, I thought I'd ask about it on the ML.]

The problem is that it silently writes invalid xml when you write an
attribute with quotes (") in it:

        xmlTextWriterWriteAttribute (writer, "attribute", "test\"test");

produces this in the output:

        attribute="test"test"

This is because  xmlTextWriterWriteAttribute uses
xmlTextWriterWriteString to write the attribute content. When in state
XML_TEXTWRITER_ATTRIBUTE, xmlTextWriterWriteString uses
xmlEncodeSpecialChars to escape characters. And xmlEncodeSpecialChars
does _not_ encode " as " as per the fix for bug
http://bugzilla.gnome.org/show_bug.cgi?id=127877.

Full testcase attached.

Regards,
        Christian


Attachment: xmlwriter.c
Description: Testcase

Attachment: test-writer.xml
Description: Output of testcase



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]