GNOME Bugzilla – Bug 126211
xmlIOParseDTD() fails if character encoding is given
Last modified: 2009-08-15 18:40:50 UTC
When calling xmlIOParseDTD(), a new xmlParserCtxt is build and xmlNewIOInputStream() is called with that context, the given xmlParserInputBufferPtr and encoding. If the encoding is unequal to XML_CHAR_ENCODING_NONE, xmlSwitchEncoding() and than xmlSwitchToEncoding() is called, again with the new parser context and the appropriate encoding handler (if found). xmlSwitchToEncoding() now checks (ctxt->input != NULL) and calls xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n", NULL); since the newly build context obviously has no input pointer. xmlErrInternal() sets ctxt->wellFormed = 0 and after xmlIOParseDTD() has called xmlParseExternalSubset(), it checks (ctxt->wellFormed) and returns NULL. Some debugging in v2.5.4 and v2.6.1 shows that switching to the given encoding fails in both versions due to the check of (ctxt->input != NULL), but only v2.6.1 sets ctxt->wellFormed = 0. As a result it's not possible to parse in a DTD using xmlIOParseDTD() with a character encoding unequal to XML_CHAR_ENCODING_NONE.
Okay, I think I fixed it (though I didn't have a way to test it) basically creating the input with xmlNewIOInputStream, then calling xmlSwitchEncoding() after the call of xmlPushInput() Commited in CVS, thanks, Daniel
This should be closed in release of libxml2-2.6.5, Daniel