GNOME Bugzilla – Bug 164556
xmlreader errors when there are only warnings
Last modified: 2016-01-06 19:03:23 UTC
When there is an error reported from the parser, the reader interface returns -1 on xmlTextReaderRead. Instead the developer should be able to handle warnings in the warning/error callback and have parsing continue. With test file <test xmlns:foo=""/> > xmllint test.xml test.xml:1: parser warning : xmlns:foo: '' is not a valid URI <test xmlns:foo=""/> ^ <?xml version="1.0"?> <test xmlns:foo=""/> With example file reader1.c: > ./reader test.xml test.xml:1: parser warning : xmlns:foo: '' is not a valid URI <test xmlns:foo=""/> ^ test.xml : failed to parse What I expect is: test.xml:1: parser warning : xmlns:foo: '' is not a valid URI <test xmlns:foo=""/> ^ 0 1 test 1 0
Created attachment 36230 [details] [review] Check that the result of xmlParseChunk is an error
Okay, I know where the problem comes from, reproduced it and looked at the patch. It seems to me the error is not at the xmlreader level, but xmlParseChunk() returning non-0 even if the document is still well-formed. The 3 first parts of your patch are a workaround, but better fixed in xmlParseChunk() directly which I did. That fix is in CVS now. Regarding the other sections of your patch, removal ofxmlTextReaderGetParserLineNumber() and xmlTextReaderGetParserColumnNumber() are clearly bogus, you diffed agains a new version where those entries were added. The change for xmlTextReaderHasAttributes() would similary revert a fix introduced in CVS since. So fixed in CVS, thanks though the fix is different from the suggested patch, Daniel
Ah, sorry the other parts of the patch shouldn't have been there. I have a few too many versions of libxml2 on my system :). Thanks for finding the underlying cause.
So this fix appears in the modern git repository as: https://git.gnome.org/browse/libxml2/commit/?id=b8590d4c1a94b29fd55b7974ff2b77e135813c91 However, the fix appears to have been inadvertently reverted in this commit just 8 hours, 23 minutes later (since the revert is not mentioned in the ChangeLog): https://git.gnome.org/browse/libxml2/commit/?id=1441251f851f011cd34edaff9095374d5e6f7b14 And then the test added by b8590d4c1a94b29fd55b7974ff2b77e135813c91 was removed here: https://git.gnome.org/browse/libxml2/commit/?id=d7af555327843a9938a913205ac703c13c225603 The fourth part of the patch to parser.c from b8590d4c1a94b29fd55b7974ff2b77e135813c91 was actually re-fixed in Bug 684774: https://git.gnome.org/browse/libxml2/commit/?id=6c91aa384f48ff6d406553a6dd47fd556c1ef2e6 However, the original three fixes that changed "(ctxt->errNo != XML_ERR_OK)" to "(ctxt->wellFormed != 1)" are still present in trunk!