1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-21 14:53:44 +03:00

fixed bug #125811 related to DTD post validation where the DTD doesn't

* valid.c: fixed bug #125811 related to DTD post validation
  where the DTD doesn't pertain to a document.
Daniel
This commit is contained in:
Daniel Veillard
2003-11-03 16:20:10 +00:00
parent 61b9338c0f
commit a8ff65d784
2 changed files with 16 additions and 6 deletions

View File

@@ -1,3 +1,8 @@
Mon Nov 3 17:18:22 CET 2003 Daniel Veillard <daniel@veillard.com>
* valid.c: fixed bug #125811 related to DTD post validation
where the DTD doesn't pertain to a document.
Mon Nov 3 15:25:58 CET 2003 Daniel Veillard <daniel@veillard.com> Mon Nov 3 15:25:58 CET 2003 Daniel Veillard <daniel@veillard.com>
* parser.c xmlIO.c include/libxml/parserInternals.h: implemented * parser.c xmlIO.c include/libxml/parserInternals.h: implemented

17
valid.c
View File

@@ -6039,7 +6039,7 @@ xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) {
xmlNodePtr child; xmlNodePtr child;
xmlAttrPtr attr; xmlAttrPtr attr;
xmlNsPtr ns; xmlNsPtr ns;
xmlChar *value; const xmlChar *value;
int ret = 1; int ret = 1;
if (elem == NULL) return(0); if (elem == NULL) return(0);
@@ -6067,7 +6067,7 @@ xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) {
value = xmlNodeListGetString(doc, attr->children, 0); value = xmlNodeListGetString(doc, attr->children, 0);
ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value); ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value);
if (value != NULL) if (value != NULL)
xmlFree(value); xmlFree((char *)value);
attr= attr->next; attr= attr->next;
} }
ns = elem->nsDef; ns = elem->nsDef;
@@ -6314,7 +6314,7 @@ xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
const xmlChar *name ATTRIBUTE_UNUSED) { const xmlChar *name ATTRIBUTE_UNUSED) {
int ret; int ret;
xmlDocPtr doc; xmlDocPtr doc;
xmlElementPtr elem; xmlElementPtr elem = NULL;
if (cur == NULL) if (cur == NULL)
return; return;
@@ -6350,15 +6350,20 @@ xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
} }
if (cur->atype == XML_ATTRIBUTE_NOTATION) { if (cur->atype == XML_ATTRIBUTE_NOTATION) {
doc = cur->doc; doc = cur->doc;
if ((doc == NULL) || (cur->elem == NULL)) { if (cur->elem == NULL) {
xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlValidateAttributeCallback(%s): internal error\n", "xmlValidateAttributeCallback(%s): internal error\n",
(const char *) cur->name); (const char *) cur->name);
return; return;
} }
elem = xmlGetDtdElementDesc(doc->intSubset, cur->elem);
if (elem == NULL) if (doc != NULL)
elem = xmlGetDtdElementDesc(doc->intSubset, cur->elem);
if ((elem == NULL) && (doc != NULL))
elem = xmlGetDtdElementDesc(doc->extSubset, cur->elem); elem = xmlGetDtdElementDesc(doc->extSubset, cur->elem);
if ((elem == NULL) && (cur->parent != NULL) &&
(cur->parent->type == XML_DTD_NODE))
elem = xmlGetDtdElementDesc((xmlDtdPtr) cur->parent, cur->elem);
if (elem == NULL) { if (elem == NULL) {
xmlErrValidNode(ctxt, NULL, XML_DTD_UNKNOWN_ELEM, xmlErrValidNode(ctxt, NULL, XML_DTD_UNKNOWN_ELEM,
"attribute %s: could not find decl for element %s\n", "attribute %s: could not find decl for element %s\n",