1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

General fixes, XPointer improvements:

- HTMLparser.c: some fixes on auto-open of html/head/body
- encoding.c: fixed a compilation error on some gcc env
- xpath.c xpointer.[ch] xpathInternals.h: improved the
  XPointer implementation
- test/XPath/xptr/strpoint test/XPath/xptr/strrange3: added
  related XPointer tests and associated results
Daniel
This commit is contained in:
Daniel Veillard
2000-11-24 23:36:01 +00:00
parent 851c59c20e
commit f62ceffb7e
16 changed files with 400 additions and 59 deletions

View File

@ -855,13 +855,13 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
}
if ((xmlStrEqual(newtag, BAD_CAST"body")) || (xmlStrEqual(newtag, BAD_CAST"head")))
return;
if (ctxt->nameNr <= 1) {
if ((xmlStrEqual(newtag, BAD_CAST"script")) ||
(xmlStrEqual(newtag, BAD_CAST"style")) ||
(xmlStrEqual(newtag, BAD_CAST"meta")) ||
(xmlStrEqual(newtag, BAD_CAST"link")) ||
(xmlStrEqual(newtag, BAD_CAST"title")) ||
(xmlStrEqual(newtag, BAD_CAST"base"))) {
if ((ctxt->nameNr <= 1) &&
((xmlStrEqual(newtag, BAD_CAST"script")) ||
(xmlStrEqual(newtag, BAD_CAST"style")) ||
(xmlStrEqual(newtag, BAD_CAST"meta")) ||
(xmlStrEqual(newtag, BAD_CAST"link")) ||
(xmlStrEqual(newtag, BAD_CAST"title")) ||
(xmlStrEqual(newtag, BAD_CAST"base")))) {
/*
* dropped OBJECT ... i you put it first BODY will be
* assumed !
@ -872,14 +872,25 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"head"));
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
ctxt->sax->startElement(ctxt->userData, BAD_CAST"head", NULL);
} else {
#ifdef DEBUG
xmlGenericError(xmlGenericErrorContext,"Implied element body: pushed body\n");
#endif
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"body"));
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
ctxt->sax->startElement(ctxt->userData, BAD_CAST"body", NULL);
} else if ((!xmlStrEqual(newtag, BAD_CAST"noframes")) &&
(!xmlStrEqual(newtag, BAD_CAST"frame")) &&
(!xmlStrEqual(newtag, BAD_CAST"frameset"))) {
int i;
for (i = 0;i < ctxt->nameNr;i++) {
if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"body")) {
return;
}
if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"head")) {
return;
}
}
#ifdef DEBUG
xmlGenericError(xmlGenericErrorContext,"Implied element body: pushed body\n");
#endif
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"body"));
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
ctxt->sax->startElement(ctxt->userData, BAD_CAST"body", NULL);
}
}
@ -2932,6 +2943,41 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
*/
htmlCheckImplied(ctxt, name);
/*
* Avoid html at any level > 0, head at any level != 1
* or any attempt to recurse body
*/
if ((ctxt->nameNr > 0) && (xmlStrEqual(name, BAD_CAST"html"))) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
"htmlParseStartTag: misplaced <html> tag\n");
ctxt->wellFormed = 0;
xmlFree(name);
return;
}
if ((ctxt->nameNr != 1) &&
(xmlStrEqual(name, BAD_CAST"head"))) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
"htmlParseStartTag: misplaced <head> tag\n");
ctxt->wellFormed = 0;
xmlFree(name);
return;
}
if (xmlStrEqual(name, BAD_CAST"body")) {
int i;
for (i = 0;i < ctxt->nameNr;i++) {
if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"body")) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
"htmlParseStartTag: misplaced <body> tag\n");
ctxt->wellFormed = 0;
xmlFree(name);
return;
}
}
}
/*
* Now parse the attributes, it ends up with the ending
*