*** push_parser_patch.diff *** this patch fixes a bug in the push parser implementation: *** if the push parser recieves a single character in the epilog *** at the end of the document, it will not report an error. this happens *** because the parser will not access any input in the misc section that *** is shorter than 2 characters. *** *** i don't think this patch is most beautiful, but it handles this case *** correctly. *** *** start diff *** parser.c Sun Oct 13 13:15:44 2002 --- parser.c.patched Sun Oct 13 13:15:30 2002 *************** *** 8894,8899 **** --- 8894,8905 ---- /* * Check for termination */ + int avail = 0; + if (ctxt->input->buf == NULL) + avail = ctxt->input->length - (ctxt->input->cur - ctxt->input->base); + else + avail = ctxt->input->buf->buffer->use - (ctxt->input->cur - ctxt->input->base); + if ((ctxt->instate != XML_PARSER_EOF) && (ctxt->instate != XML_PARSER_EPILOG)) { ctxt->errNo = XML_ERR_DOCUMENT_END; *************** *** 8903,8908 **** --- 8909,8923 ---- ctxt->wellFormed = 0; ctxt->disableSAX = 1; } + if ( ctxt->instate == XML_PARSER_EPILOG && avail > 0 ) { + ctxt->errNo = XML_ERR_DOCUMENT_END; + if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) + ctxt->sax->error(ctxt->userData, + "Extra content at the end of the document\n"); + ctxt->wellFormed = 0; + ctxt->disableSAX = 1; + + } if (ctxt->instate != XML_PARSER_EOF) { if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) ctxt->sax->endDocument(ctxt->userData);