mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
fixing #109227 providing more context in case of start/end tag mismatch
* parser.c: fixing #109227 providing more context in case of start/end tag mismatch * python/tests/ctxterror.py python/tests/readererr.py: update the tests accordingly Daniel
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Thu Mar 27 15:53:35 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* parser.c: fixing #109227 providing more context in case of
|
||||||
|
start/end tag mismatch
|
||||||
|
* python/tests/ctxterror.py python/tests/readererr.py: update the
|
||||||
|
tests accordingly
|
||||||
|
|
||||||
Thu Mar 27 15:22:41 CET 2003 Daniel Veillard <daniel@veillard.com>
|
Thu Mar 27 15:22:41 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* xinclude.c: should fix #109327 errors on memory accesses
|
* xinclude.c: should fix #109327 errors on memory accesses
|
||||||
|
52
parser.c
52
parser.c
@ -6795,7 +6795,7 @@ failed:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlParseEndTag:
|
* xmlParseEndTagInternal:
|
||||||
* @ctxt: an XML parser context
|
* @ctxt: an XML parser context
|
||||||
*
|
*
|
||||||
* parse an end of tag
|
* parse an end of tag
|
||||||
@ -6807,8 +6807,8 @@ failed:
|
|||||||
* [NS 9] ETag ::= '</' QName S? '>'
|
* [NS 9] ETag ::= '</' QName S? '>'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
xmlParseEndTag(xmlParserCtxtPtr ctxt) {
|
xmlParseEndTagInternal(xmlParserCtxtPtr ctxt, int line) {
|
||||||
xmlChar *name;
|
xmlChar *name;
|
||||||
xmlChar *oldname;
|
xmlChar *oldname;
|
||||||
|
|
||||||
@ -6850,28 +6850,16 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) {
|
|||||||
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) {
|
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) {
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
ctxt->sax->error(ctxt->userData,
|
ctxt->sax->error(ctxt->userData,
|
||||||
"Opening and ending tag mismatch: %s and %s\n",
|
"Opening and ending tag mismatch: %s line %d and %s\n",
|
||||||
ctxt->name, name);
|
ctxt->name, line, name);
|
||||||
} else {
|
} else {
|
||||||
ctxt->sax->error(ctxt->userData,
|
ctxt->sax->error(ctxt->userData,
|
||||||
"Ending tag error for: %s\n", ctxt->name);
|
"Ending tag error for: %s line %d\n", ctxt->name, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ctxt->wellFormed = 0;
|
ctxt->wellFormed = 0;
|
||||||
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
|
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
|
||||||
#if 0
|
|
||||||
else {
|
|
||||||
/*
|
|
||||||
* Recover in case of one missing close
|
|
||||||
*/
|
|
||||||
if ((ctxt->nameNr > 2) &&
|
|
||||||
(xmlStrEqual(ctxt->nameTab[ctxt->nameNr -2], name))) {
|
|
||||||
namePop(ctxt);
|
|
||||||
spacePop(ctxt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
xmlFree(name);
|
xmlFree(name);
|
||||||
}
|
}
|
||||||
@ -6894,6 +6882,24 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlParseEndTag:
|
||||||
|
* @ctxt: an XML parser context
|
||||||
|
*
|
||||||
|
* parse an end of tag
|
||||||
|
*
|
||||||
|
* [42] ETag ::= '</' Name S? '>'
|
||||||
|
*
|
||||||
|
* With namespace
|
||||||
|
*
|
||||||
|
* [NS 9] ETag ::= '</' QName S? '>'
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
xmlParseEndTag(xmlParserCtxtPtr ctxt) {
|
||||||
|
xmlParseEndTagInternal(ctxt, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlParseCDSect:
|
* xmlParseCDSect:
|
||||||
* @ctxt: an XML parser context
|
* @ctxt: an XML parser context
|
||||||
@ -7129,6 +7135,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
|||||||
xmlChar *name;
|
xmlChar *name;
|
||||||
xmlChar *oldname;
|
xmlChar *oldname;
|
||||||
xmlParserNodeInfo node_info;
|
xmlParserNodeInfo node_info;
|
||||||
|
int line;
|
||||||
xmlNodePtr ret;
|
xmlNodePtr ret;
|
||||||
|
|
||||||
/* Capture start position */
|
/* Capture start position */
|
||||||
@ -7143,6 +7150,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
|||||||
else
|
else
|
||||||
spacePush(ctxt, *ctxt->space);
|
spacePush(ctxt, *ctxt->space);
|
||||||
|
|
||||||
|
line = ctxt->input->line;
|
||||||
name = xmlParseStartTag(ctxt);
|
name = xmlParseStartTag(ctxt);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
spacePop(ctxt);
|
spacePop(ctxt);
|
||||||
@ -7191,8 +7199,8 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
|||||||
ctxt->errNo = XML_ERR_GT_REQUIRED;
|
ctxt->errNo = XML_ERR_GT_REQUIRED;
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
||||||
ctxt->sax->error(ctxt->userData,
|
ctxt->sax->error(ctxt->userData,
|
||||||
"Couldn't find end of Start Tag %s\n",
|
"Couldn't find end of Start Tag %s line %d\n",
|
||||||
name);
|
name, line);
|
||||||
ctxt->wellFormed = 0;
|
ctxt->wellFormed = 0;
|
||||||
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
|
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
|
||||||
|
|
||||||
@ -7230,7 +7238,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
|||||||
ctxt->errNo = XML_ERR_TAG_NOT_FINISHED;
|
ctxt->errNo = XML_ERR_TAG_NOT_FINISHED;
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
||||||
ctxt->sax->error(ctxt->userData,
|
ctxt->sax->error(ctxt->userData,
|
||||||
"Premature end of data in tag %s\n", name);
|
"Premature end of data in tag %s line %d\n", name, line);
|
||||||
ctxt->wellFormed = 0;
|
ctxt->wellFormed = 0;
|
||||||
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
|
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
|
||||||
|
|
||||||
@ -7252,7 +7260,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
|||||||
/*
|
/*
|
||||||
* parse the end of tag: '</' should be here.
|
* parse the end of tag: '</' should be here.
|
||||||
*/
|
*/
|
||||||
xmlParseEndTag(ctxt);
|
xmlParseEndTagInternal(ctxt, line);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Capture end position and add node
|
* Capture end position and add node
|
||||||
|
@ -10,7 +10,7 @@ import libxml2
|
|||||||
libxml2.debugMemory(1)
|
libxml2.debugMemory(1)
|
||||||
|
|
||||||
expect="""--> (3) xmlns: URI foo is not absolute
|
expect="""--> (3) xmlns: URI foo is not absolute
|
||||||
--> (4) Opening and ending tag mismatch: x and y
|
--> (4) Opening and ending tag mismatch: x line 0 and y
|
||||||
"""
|
"""
|
||||||
|
|
||||||
err=""
|
err=""
|
||||||
|
@ -10,7 +10,7 @@ import sys
|
|||||||
libxml2.debugMemory(1)
|
libxml2.debugMemory(1)
|
||||||
|
|
||||||
expect="""--> (3) test1:1:xmlns: URI foo is not absolute
|
expect="""--> (3) test1:1:xmlns: URI foo is not absolute
|
||||||
--> (4) test1:1:Opening and ending tag mismatch: c and a
|
--> (4) test1:1:Opening and ending tag mismatch: c line 0 and a
|
||||||
"""
|
"""
|
||||||
err=""
|
err=""
|
||||||
def myErrorHandler(arg,msg,severity,locator):
|
def myErrorHandler(arg,msg,severity,locator):
|
||||||
|
Reference in New Issue
Block a user