From e715dd25dd99b9d7d883892f5871dfc87a220de4 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Tue, 29 Aug 2000 18:29:38 +0000 Subject: [PATCH] - parser.c: Fixed bug on invalid ontent characters and when using push. - xmllint.c: fixed xmllint endling of errors in push mode Daniel --- ChangeLog | 6 ++++++ parser.c | 23 ++++++++++++++++++++++- xmllint.c | 6 ++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 38a1fba9..c156f19c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Aug 29 20:22:53 CEST 2000 Daniel Veillard + + * parser.c: Fixed bug on invalid ontent characters and when using + push. + * xmllint.c: fixed xmllint endling of errors in push mode + Tue Aug 29 11:24:48 CEST 2000 Daniel Veillard * HTMLparser.c testHTML.c: applied two new patches from diff --git a/parser.c b/parser.c index dd9b98ff..1cc980e4 100644 --- a/parser.c +++ b/parser.c @@ -8597,6 +8597,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) { ctxt->errNo = XML_ERR_INTERNAL_ERROR; ctxt->wellFormed = 0; ctxt->disableSAX = 1; + ctxt->instate = XML_PARSER_EOF; break; } } @@ -9982,7 +9983,11 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { #endif break; } - case XML_PARSER_CONTENT: + case XML_PARSER_CONTENT: { + const xmlChar *test; + int cons; + xmlChar tok; + /* * Handle preparsed entities and charRef */ @@ -9999,6 +10004,10 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { goto done; cur = ctxt->input->cur[0]; next = ctxt->input->cur[1]; + + test = CUR_PTR; + cons = ctxt->input->consumed; + tok = ctxt->token; if ((cur == '<') && (next == '?')) { if ((!terminate) && (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) @@ -10082,7 +10091,19 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { */ while ((RAW == 0) && (ctxt->inputNr > 1)) xmlPopInput(ctxt); + if ((cons == ctxt->input->consumed) && (test == CUR_PTR) && + (tok == ctxt->token)) { + if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) + ctxt->sax->error(ctxt->userData, + "detected an error in element content\n"); + ctxt->errNo = XML_ERR_INTERNAL_ERROR; + ctxt->wellFormed = 0; + ctxt->disableSAX = 1; + ctxt->instate = XML_PARSER_EOF; + break; + } break; + } case XML_PARSER_CDATA_SECTION: { /* * The Push mode need to have the SAX callback for diff --git a/xmllint.c b/xmllint.c index f9d96849..bfa60109 100644 --- a/xmllint.c +++ b/xmllint.c @@ -382,6 +382,7 @@ void parseAndPrintFile(char *filename) { f = fopen(filename, "r"); if (f != NULL) { + int ret; int res, size = 3; char chars[1024]; xmlParserCtxtPtr ctxt; @@ -397,7 +398,12 @@ void parseAndPrintFile(char *filename) { } xmlParseChunk(ctxt, chars, 0, 1); doc = ctxt->myDoc; + ret = ctxt->wellFormed; xmlFreeParserCtxt(ctxt); + if (!ret) { + xmlFreeDoc(doc); + doc = NULL; + } } } } else if (testIO) {