1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-30 22:43:14 +03:00

fixing a too early root closing problem raised byt Prashanth Naidu Daniel

* HTMLparser.c: fixing a too early root closing problem raised
  byt Prashanth Naidu
Daniel
This commit is contained in:
Daniel Veillard
2001-07-04 16:04:09 +00:00
parent 8c357d58c2
commit f420ac55f8
2 changed files with 26 additions and 11 deletions

View File

@ -1,3 +1,8 @@
Wed Jul 4 18:02:58 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* HTMLparser.c: fixing a too early root closing problem raised
byt Prashanth Naidu
Wed Jul 4 01:42:01 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Wed Jul 4 01:42:01 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* xpath.c: fixed a missing copy in xmlXPathVariableLookupNS() * xpath.c: fixed a missing copy in xmlXPathVariableLookupNS()

View File

@ -3084,24 +3084,26 @@ failed:
* With namespace * With namespace
* *
* [NS 9] ETag ::= '</' QName S? '>' * [NS 9] ETag ::= '</' QName S? '>'
*
* Returns 1 if the current level should be closed.
*/ */
static void static int
htmlParseEndTag(htmlParserCtxtPtr ctxt) { htmlParseEndTag(htmlParserCtxtPtr ctxt) {
xmlChar *name; xmlChar *name;
xmlChar *oldname; xmlChar *oldname;
int i; int i, ret;
if ((CUR != '<') || (NXT(1) != '/')) { if ((CUR != '<') || (NXT(1) != '/')) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData, "htmlParseEndTag: '</' not found\n"); ctxt->sax->error(ctxt->userData, "htmlParseEndTag: '</' not found\n");
ctxt->wellFormed = 0; ctxt->wellFormed = 0;
return; return(0);
} }
SKIP(2); SKIP(2);
name = htmlParseHTMLName(ctxt); name = htmlParseHTMLName(ctxt);
if (name == NULL) return; if (name == NULL) return(0);
/* /*
* We should definitely be at the ending "S? '>'" part * We should definitely be at the ending "S? '>'" part
@ -3127,7 +3129,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) {
"Unexpected end tag : %s\n", name); "Unexpected end tag : %s\n", name);
xmlFree(name); xmlFree(name);
ctxt->wellFormed = 0; ctxt->wellFormed = 0;
return; return(0);
} }
@ -3174,12 +3176,15 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) {
xmlGenericError(xmlGenericErrorContext,"End of tag %s: stack empty !!!\n", name); xmlGenericError(xmlGenericErrorContext,"End of tag %s: stack empty !!!\n", name);
#endif #endif
} }
ret = 1;
} else {
ret = 0;
} }
if (name != NULL) if (name != NULL)
xmlFree(name); xmlFree(name);
return; return(ret);
} }
@ -3285,17 +3290,22 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
* Our tag or one of it's parent or children is ending. * Our tag or one of it's parent or children is ending.
*/ */
if ((CUR == '<') && (NXT(1) == '/')) { if ((CUR == '<') && (NXT(1) == '/')) {
htmlParseEndTag(ctxt); if (htmlParseEndTag(ctxt) &&
if (currentNode != NULL) xmlFree(currentNode); ((currentNode != NULL) || (ctxt->nameNr == 0))) {
if (currentNode != NULL)
xmlFree(currentNode);
return; return;
} }
continue; /* while */
}
/* /*
* Has this node been popped out during parsing of * Has this node been popped out during parsing of
* the next element * the next element
*/ */
if ((!xmlStrEqual(currentNode, ctxt->name)) && if ((ctxt->nameNr > 0) && (depth >= ctxt->nameNr) &&
(depth >= ctxt->nameNr)) { (!xmlStrEqual(currentNode, ctxt->name)))
{
if (currentNode != NULL) xmlFree(currentNode); if (currentNode != NULL) xmlFree(currentNode);
return; return;
} }